奖学金

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;
    }
        }




最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容