标签:
package lianxi; import java.util.*; public class Xvexichengji { public static void main(String[] args) { System.out.println("输入姓名"); Scanner xingming = new Scanner(System.in); String ren = xingming.next(); System.out.println("输入成绩"); while (true) { Scanner chengji = new Scanner(System.in); Double shu = chengji.nextDouble(); if (shu > 100 || shu < 0) { System.out.println("输入的成绩有误,请重新输入"); continue; } else { if (shu >= 90) { System.out.println(ren+"的成绩为A"); break; } else if (shu < 60) { System.out.println(ren+"的成绩为C"); break; } else { System.out.println(ren+"的成绩为B"); break; } } } } }
利用条件运算符的嵌套来完成此题:学习成绩> =90分的同学用A表示,60-89分之间的用B表示,60分以下的用C表示。
标签:
原文地址:http://www.cnblogs.com/wenwen123/p/5492248.html