利用条件运算符的嵌套来完成此题:学习成绩> =90分的同学用A表示,60-89分之间的用B表示,60分以下的用C表示。

package com.hanqi;
import java.util.*;
public class xuexichengji {

    public static void main(String[] args) {
        // TODO 自动生成的方法存根
        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;
                }
            }
        }
    }



    }

posted @ 2016-05-15 22:42  尤痴武  阅读(1010)  评论(0)    收藏  举报