/*
根据键盘录入的成绩,判断等级。
*/
import java.util.Scanner;
class ScannerScoreTest
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("请输入分数1-100");
int score = sc.nextInt();
String s;
if(score <= 100&&score >= 90){
s = "A等";
}else if(score < 90 && score >= 80){
s = "B等";
}else if(score < 80 && score >= 70){
s = "C等";
}else if(score < 70 && score >= 60){
s = "D等";
}else if(score < 60 && score >= 0){
s = "E等";
}else{
s = "分数有误";
}
System.out.println(s);
}
}
这个程序为什么输入1-100之间运行都正确,输入1-100以外的结果不是输出“分数有误”而是输出“B”???
|