zoukankan      html  css  js  c++  java
  • java 每日习题(八)利用条件运算符嵌套完成成绩分级

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

    条件运行算可以嵌套使用

    package everyDay;
    
    import java.util.Scanner;
    
    public class ScoreGrade {
    
        public static void main(String[] args) {
    
            while (true) {
                Scanner scan = new Scanner(System.in);
                String score = scan.nextLine();
                int s = Integer.parseInt(score);
                if (s <= 100 && s >= 0) {
                    String str = (s >= 90) ? "grade is A" : (s >= 60) ? "grade is B" : "grade is C";
                    System.out.println(str);
                    break;
                }else {
                    System.out.println("pleas input 0-100");
                    continue;
                }
            }
            
    
        }
    
    }
  • 相关阅读:
    英文词频统计
    字符串练习
    第八周
    第七周
    第五周
    第六周
    第三周
    第四周
    第二周
    第一周作业
  • 原文地址:https://www.cnblogs.com/mtlogs/p/4985771.html
Copyright © 2011-2022 走看看