import java.util.Scanner;
public class Demo {
public static void main(String[]args){
System.out.println("请输入成绩:");
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
grade(a);
}
public static void grade(int a){
if(a>100||a<0){
System.out.println("输入的数据有误!");
}else{
//楼主所问的条件运算符的嵌套
String s= (a>=90)?",A":(a>=60)?"分,B":"分,C";
System.out.println(a+s);
}
}
} |