[Java 教學範例拷貝]- if 條件式(完)

[Java 教學範例拷貝]- if 條件式(完)

[Java 教學範例拷貝]- if 條件式(完)

 

剛才找資料時發現一個的Java 教學網站,趕快發揮(C/P)的長才將它備份來,有需要的同好,歡迎來(C/P)一下^^。

 

拷貝來源:
http://openhome.cc/Gossip/JavaGossip-V1/
http://openhome.cc/Gossip/JavaGossip-V1/ConditionIf.htm

 

import java.util.Scanner;
public class ConditionIf {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("輸入分數:");
int score = scanner.nextInt();
if(score >= 90)
System.out.println("得A");
else if(score >= 80 && score < 90)
System.out.println("得B");
else if(score >= 70 && score < 80)
System.out.println("得C");
else if(score >= 60 && score < 70)
System.out.println("得D");
else
System.out.println("得E(不及格)");
}
}

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *