90分以上为’A’,80~89 分为’B’,70~79 分为’C’,60~69 分为’D’,60 分以下为’E’。
请输入成绩:67
请输入成绩:89
请输入成绩:56
D
B
E
package ch01入门.day_02; import java.util.Scanner; public class Test_给出百分制成绩 { public static void main(String[] args) { Scanner scan=new Scanner(System.in); for (int i = 0; i <100 ; i++) { System.out.println("请输入0-100的数字"); int x=scan.nextInt(); if (x>=90&&x<=100){ System.out.println("A"); }else if (x>=80&&x<90){ System.out.println("B"); }else if (x>=70&&x<80){ System.out.println("C"); }else if (x>=60&&x<70){ System.out.println("D"); }else if (x<60){ System.out.println("E"); }else{ System.out.println("错误"); } } } }