标签:语句 inpu eve evel java 三目运算符 等级 print 判断语句
import java.util.Scanner;
public class APPLE {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int num =input.nextInt();
String level;
if(num<0 || num>100){
System.out.println(num+"超出范围,请重新赋值");//if。。。else简单语句
}else{
switch ((int)(num/10))
{
case 10:level="非常棒";break;
case 9:level="优秀";break;
case 8:level="良好";break;
case 7:level="一般";break;
case 6:level="及格";break;
default:level="不及格";
}
System.out.println("你的分数是\t"+num+"你的等级是"+level);//switch语句
}
System.out.println((num>70)?"合格":"不合格");//三目运算符
if(num<0||num>100){ //嵌套if
System.out.println(num+"超出范围,请重新赋值");
}else if(num>=90){
System.out.println("优秀");
}else if(num>=80){
System.out.println("良好");
}else if(num>=70){
System.out.println("一般");
}else if(num>=60){
System.out.println("及格");
}else{
System.out.println("不及格");
}
}
}
标签:语句 inpu eve evel java 三目运算符 等级 print 判断语句
原文地址:http://www.cnblogs.com/ludongyang/p/7719887.html