奖学金

作者: 李哈哈_bing | 来源:发表于2018-02-13 20:22 被阅读0次
    package 奖学金;
    
    import java.util.*;
    
    /**
     * Created by ttc on 18-3-2.
     */
    public class Main {
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            System.out.println("请输入学生总数数");
            int num = scanner.nextInt();
            scanner.nextLine();
            List<StudentInof> list = new ArrayList<StudentInof>();
            for (int i = 0; i < num; i++) {
                System.out.println("请输入第" + (i + 1) + "个学生的信息");
                String inof = scanner.nextLine();
                String[] array = inof.split(" ");
                String name = array[0];
                int lastscore = Integer.parseInt(array[1]);
                int classScore = Integer.parseInt(array[2]);
                String isMaster = array[3];
                String isWestStu = array[4];
                int article = Integer.parseInt(array[5]);
                StudentInof studentInof = new StudentInof();
                studentInof.setName(name);
                studentInof.setScore(lastscore);
                studentInof.setClassScore(classScore);
                studentInof.setClassMaster(isMaster);
                studentInof.setWestStu(isWestStu);
                studentInof.setArticlecount(article);
                list.add(studentInof);
    
            }
    
            for (int i = 0; i < list.size(); i++) {
                int money = 0;
                if (list.get(i).getScore() > 80 && (list.get(i).getArticlecount() >= 1)) {
                    money += 8000;
                    list.get(i).setEachMonery(money);
                }
                if (list.get(i).getScore() > 85 && (list.get(i).getClassScore() > 80)) {
                    money += 4000;
                    list.get(i).setEachMonery(money);
                }
    
                if (list.get(i).getScore() > 90) {
                    money += 2000;
                    list.get(i).setEachMonery(money);
                }
                if (list.get(i).getScore() > 85 && (list.get(i).getWestStu().equals("Y"))) {
                    money += 1000;
                    list.get(i).setEachMonery(money);
                }
                if (list.get(i).getClassScore() > 80 && (list.get(i).getClassMaster().equals("Y"))) {
                    money += 850;
                    list.get(i).setEachMonery(money);
                }
            }
    
            //输出
            Map<Integer, String> money2Nmae = new HashMap<Integer, String>();
            List<Integer> listMoney = new ArrayList<Integer>();
            int allmoney = 0;
            for (int i = 0; i < num; i++) {
    
                money2Nmae.put(list.get(i).getEachMonery(), list.get(i).getName());
                listMoney.add(list.get(i).getEachMonery());
                allmoney += list.get(i).getEachMonery();
            }
    
    
    
            Collections.sort(listMoney);
            System.out.println(money2Nmae.get(listMoney.get(num - 1)) + "是最高奖学金的获得者");
            System.out.println(listMoney.get(num - 1));
            System.out.println(allmoney);
        }
    }
    //YaoLin 87 82 true false 0
    //ChenRuiyi 88 78 false true 1
    //LiXin 92 88 false false 0
    //ZhangQin 83 87 true false 1
    
    package 奖学金;
    
    /**
     * Created by ttc on 18-3-2.
     */
    public class StudentInof {
      private   String name;
        private  int score;
        private  int classScore;
        private  String classMaster;
        private  String westStu;
        private  int articlecount;
        private  int eachMonery;
    
        public String getName() {
            return name;
        }
    
        public void setName(String name) {
            this.name = name;
        }
    
        public int getScore() {
            return score;
        }
    
        public void setScore(int score) {
            this.score = score;
        }
    
        public int getClassScore() {
            return classScore;
        }
    
        public void setClassScore(int classScore) {
            this.classScore = classScore;
        }
    
        public String getClassMaster() {
            return classMaster;
        }
    
        public void setClassMaster(String classMaster) {
            this.classMaster = classMaster;
        }
    
        public String getWestStu() {
            return westStu;
        }
    
        public void setWestStu(String westStu) {
            this.westStu = westStu;
        }
    
        public int getArticlecount() {
            return articlecount;
        }
    
        public void setArticlecount(int articlecount) {
            this.articlecount = articlecount;
        }
    
        public int getEachMonery() {
            return eachMonery;
        }
    
        public void setEachMonery(int eachMonery) {
            this.eachMonery = eachMonery;
        }
            }
    
    
    
    
    

    相关文章

      网友评论

          本文标题:奖学金

          本文链接:https://www.haomeiwen.com/subject/bawjtftx.html