Here is my code:
switch(age) {
case 10:
System.out.println("You are too young to drive.");
break;
case 20:
System.out.println("You can drive!");
break;
default:
System.out.println("Error");
}
What happens if the age is 15? Well, it gives me an error. So I was wondering if it's possible to include a condition within the case. For example,
case (age>=10 && age<=20):
System.out.println("You're still too young to drive...");
break;
I could use an if statement, but I'm wondering if this is possible with a switch.