我有应该可以工作的代码,但是底部的大括号给了我一个错误。可能有一个我找不到的简单解决方案,可能是因为我已经筋疲力尽了。这两个代码都属于不同的类。如果我删除一个大括号,那么另一个大括号会给我一个错误。
import java.util.Scanner;
public class question {
public static void main(String[] args) {
int a = 0;
int b = 0;
int c = 0;
int d = 0;
int f = 0;
int grade = 0;
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter grade scores: ");
do {
System.out.print("Grade: ");
grade = keyboard.nextInt();
if (grade >= 0 && grade < 60) {
f++;
} else if (grade < 70) {
d++;
} else if (grade < 80) {
c++;
} else if (grade < 90) {
b++;
} else if (grade <= 100) {
a++;
}
while (grade >= 0) {
System.out.println("Total scores: " + (a + b + c + d + f));
System.out.println("A: " + a);
System.out.println("B: " + b);
System.out.println("C: " + c);
System.out.println("D: " + d);
System.out.println("F: " + f);
}
} // this one gives error
}
}