public class ChengJi {
public static void main(String[] args) {
int x;
char grade;
Scanner s = new Scanner(System.in);
System.out.print("Please input Grade: ");
x = s.nextInt();
if (x > 100) {
System.out.println("Grade is Duang~~");
}
if (x < 0) {
System.out.println("The Childer is WanDuZi le");
}
if (x > 0 && x < 101) {
/*這是什麼格式的寫法?,有點像三目運算啊*/
grade = x >= 90 ? 'A' : x >= 60 ? 'B' : 'C';
System.out.println("Lev:" + grade);
}
}
}
條件表達式。這裡是2個條件表達式嵌套了。