• 包装类练习


    package lianxi3;
    
    import java.util.Scanner;
    import java.util.Vector;
    
    public class TestScore {
    
        public static void main(String[] args) {
            // 1.从键盘输入学生成绩,输入负数结束
            // 2.将学生成绩保存在Vector数组
            Scanner s = new Scanner(System.in);
            System.out.println("从键盘输入学生成绩,输入负数结束");
            Vector v = new Vector();
            int max = 0;
            // while(s.nextInt()>0){
            for (;;) {
                int score = s.nextInt();
                if (score < 0) {
                    break;
                }
                Integer score1 = score;
                v.addElement(score1);
                if (score > max) {
                    max = score;
                }
            }
    
            // 3.找出最大值
            System.out.println("max=" + max);
            // 4.遍历Vector数组,打印学生的成绩等级
            for (int i = 0; i < v.size(); i++) {
                Integer in = (Integer) v.elementAt(i);
                int a = in;
                int degree = max - a;
                char level;
                if (degree <= 10) {
                    level = 'A';
    
                } else if (degree <= 20) {
                    level = 'B';
    
                } else if (degree <= 30) {
                    level = 'C';
    
                } else {
                    level = 'D';
    
                }
                System.out.println("学生成绩:" + a + "成绩等级:" + level);
            }
    
        }
    }
  • 相关阅读:
    Labeling Balls
    Following Orders
    Frame Stacking
    Window Pains
    Sort it all out
    Ferry Loading||
    今年暑假不AC
    xcode10 出现 框架 或者 pod 出错
    网络请求 步骤
    swift UIAlertController使用 UIAlertController的宽度 为270
  • 原文地址:https://www.cnblogs.com/yjtm53/p/4135135.html
Copyright © 2020-2023  润新知