Can I make my switch statement check if a value is more or less than something else (see the example below)? As it is, it doesn’t work, unfortunately. I can make a sequence of if-else statements, but switch seems to be the obvious choice when you check the state of only one variable
public static String getGreeting(){
double rd = Math.random();
String greeting;
switch(rd){
case < 0.2:
greeting = "Hello!";
break;
case < 0.4:
greeting = "Hi there!";
break;
case < 0.6:
greeting = "Nice to see you!";
break;
case < 0.8:
greeting = "Greetings!";
break;
default:
greeting = "Aloha!";
}
return greeting;
}