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 }