Conditional Operators
-
Used when evaluating conditional expression
-
= = (double equal, not single!)
-
!=
-
<
-
>
-
>=
-
<=
if (cash <= 3.50) {
System.out.println("Not enough money for a hot
dog
at Cinergy");
} else if (cash < 6.00) {
System.out.println("Not enough money for a
coffee
at Starbucks");
} else if (cash == 6.00) {
System.out.println("Exactly enough for a coffee
at Starbucks!);
} else if (cash <= 15.00) {
System.out.println("Almost enough money to park
downtown for a day");
} else {
System.out.println("Dude, you are
loaded!");
}
Conditional Expressions
Home
Internet II: Day 2