1 package com.gsa.homework; 2 3 import java.util.Scanner; 4 5 import javax.swing.JOptionPane; 6 7 8 public class HomeWork032801 { 9 10 /** 11 * 1、給出一百分制成績,要求輸出成績等級’A’、’B’、’C’、’D’、’E’。 12 * 90分以上為’A’,80~89分為’B’、70~79分為’C’,60~69分為’D’,60分以下為’E’。 13 */ 14 public static void main(String[] args) { 15 int score; 16 // score = Integer.parseInt(JOptionPane.showInputDialog("請輸入百分制成績: ")); // 對話框 17 Scanner s=new Scanner(System.in); 18 System.out.println("請輸入一個整數"); 19 score=s.nextInt(); 20 if (score>100 || score<0) { 21 System.out.println("超出范圍!!!"); 22 } 23 else if (score>=90) { 24 System.out.println("成績等級:"+ 'A'); 25 } 26 else if (score>=80) { 27 System.out.println("成績等級:"+ 'B'); 28 } 29 else if (score>=70) { 30 System.out.println("成績等級:"+ 'C'); 31 } 32 else if (score>=60) { 33 System.out.println("成績等級:"+ 'D'); 34 } 35 else if (score<60) { 36 System.out.println("成績等級:"+ 'E'); 37 } 38 } 39 40 }