I am trying to get my head around switch statements. I understand how to use a switch statement using a single variable but I cannot workout how to make the following code segment work:
If they cannot be done like this ( I struggled to find any info in google) could you please suggest a more effective way that would work if I wanted to add more cases which is why I am reluctant to use if statements.)
Edit: I'm not sure that my question was understood properly. I was wondering if it is possible to use the "And" and "OR" operators in a switch statement to make a switch statement that checks that two different variables match the requirements of each case. E.G Boy and girl are over 10, girl or boy are over 10, etc... I was asking for a Switch statement Solution specifically as this is more of a tutorial program than a useful program.
Also its really annoying getting my question marked down as being a duplicate when none of the so called "answers" that already exist answer my question and the many many unhelpful comments that ignore my question really suck.
enter code here
public class AgeCheck {
public static void main(String args[]){
int boy, girl;
boy = 21;
girl = 22;
switch(boy & girl){
case 1: boy > 10 && girl > 10;
break;
System.out.println("You can enter...");
case 2: boy || girl < 10;
System.out.println("You cannot enter, someone amongst you is unworthy...");
break;
default:
System.out.println("Your age is unknown...");
}
}
}