解题思路:利用循环判断输入的数是否为0 其他用计数器统计
注意事项:优秀是大于等于85!!!!!!!!!!!!!!!
参考代码:import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int excellent = 0; //优秀
int good = 0;
int failed = 0;
while (n != 0) {
if(n >= 85)
excellent++;
else if(n >= 60)
good++;
else
failed++;
n = sc.nextInt();
}
System.out.println(">=85:" + excellent);
System.out.println("60-84:" + good);
System.out.println("<60:" + failed);
}
}
0.0分
0 人评分