学校即将举行期末考试,校评分机构会根据不同的成绩给予考生不同的期末评价,请用程序实现考生应该获得什么样的评价,并在控制台输出。
import java.util.Scanner;
public class ScannerTest {
public static void main (String[]args){
Scanner sc=new Scanner(System.in);//创建对象
System.out.print("请输入你的分数");
int score= sc.nextInt();
if(score>100||score<0){ //多种判断,用if...else...if格式实现
System.out.print("输入的分数有误");
}else if(score>=90&&score<=100) {//为每种判断设置对应的条件
System.out.print("优秀");
}else if (score>=80&&score<=89) {
System.out.print("良好");
}else if (score>=60&&score<=79) {
System.out.print("合格");
}else{
System.out.print("不及格,回家挨揍");
}
}
}
最终结果:
请输入你的分数59 不及格,回家挨揍



