我真的是尝试学习代码的初学者,根据我阅读的文献,我创建了以下程序。这段代码的问题是我输入的任何数字都会返回 F 级。如果我删除 System.in.read() 并设置永久值,那么它就可以正常工作。有人猜我的代码有什么问题吗?
class ladder2 {
public static void main(String args[])
throws java.io.IOException {
char read, grade;
// read = 75;
System.out.println("Enter a score between 0 and 100: ");
read = (char) System.in.read();
if (100 <= read) grade = 'A';
else if (85 <= read) grade = 'B';
else if (75 <= read) grade = 'C';
else if (60 <= read) grade = 'D';
else grade = 'F';
System.out.println("GRADE " + grade);
}
}