01
int score;
System.out.println("請輸入成績");
score = sc.nextInt();
String flag;
System.out.println("是否擔任幹部?Y/N");
flag = sc.next();
if(flag.equals("Y")||flag.equals("y")) {
score=score+10;
}
System.out.println("是否曾得獎?Y/N");
flag = sc.next();
if(flag.equals("Y")||flag.equals("y")) {
score=score+10;
}
System.out.println(score);
02
int a = 10;
int ans = (a >= 0) ? 0 : 1;
System.out.println((ans > 0) ? 0 : 1);
// 判斷成績------------------
Scanner sc = new Scanner(System.in);
System.out.println("...分數...");
int score = sc.nextInt();
if (score >= 0 && score <= 100) {
switch ((score>=60)?0:1) {
case 0:
System.out.println("及格");
break;
case 1:
System.out.println("不及格");
break;
}
} else {
System.out.println("不再範圍");
}
}
沒有留言:
張貼留言