第四章選擇結構習題5

Duanhaifeng55發表於2018-03-29

//用switch語法做第三章的if else的練習題

package learn;

import java.util.Scanner;
public class Promise {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("請輸入成績:");
int score=input.nextInt();
switch(score/10) {
case 10:
System.out.println("獎勵一輛車");
break;
case 9:
System.out.println("獎勵膝上型電腦");
break;
case 8:
case 7:
case 6:
System.out.println("獎勵一部手機");
break;
default:
System.out.println("沒有禮物");
}
}
}

相關文章