public static void main(String[] args) throws Exception {
System.out.print("请输入成绩:");
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
try {
int score = Integer.parseInt(str);
if (score >= 0 && score < 60){
System.out.println("不及格");
} else if (score >= 60 && score < 75){
System.out.println("及格");
} else if (score >= 75 && score < 90) {
System.out.println("良");
} else if (score >= 90 && score <= 100){
System.out.println("优");
} else {
System.out.println("成绩无效");
}
} catch (NumberFormatException e){
System.out.println("成绩输入错误");
}
}
代码还是自己敲的好