(JAVA)简易高考志愿分析系统——实现:1.根据学校知名度排名 2.根据专业热度排名 3.计算上岸概率,根据上岸概率排名 4.根据学校知名度和专业热度自定义排名

该程序使用Java创建了一个School类,包含了学校名称、知名度、主要专业、专业热度和上岸率等属性。用户可以输入分数对应的全省位次,然后选择根据学校知名度、专业热度、上岸概率或综合排序来查询志愿。程序使用ArrayList存储School对象,并实现了多种排序算法进行数据展示。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >



import java.util.ArrayList;
import java.util.Scanner;



class School{
    private String name;//学校姓名
    private int popularity;//知名度
    private String majority;//专业
    private int development;//专业热度
    private int precedence;//上岸率
    public School() {
    }

    public School(String name, int popularity, String majority, int development,int precedence) {
        this.name = name;
        this.popularity = popularity;
        this.majority = majority;
        this.development = development;
        this.precedence = precedence;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getPopularity() {
        return popularity;
    }

    public void setPopularity(int popularity) {
        this.popularity = popularity;
    }

    public String getMajority() {
        return majority;
    }

    public void setMajority(String majority) {
        this.majority = majority;
    }

    public int getDevelopment() {
        return development;
    }

    public void setDevelopment(int development) {
        this.development = development;
    }

    public int getPrecedence() {
        return precedence;
    }

    public void setPrecedence(int precedence) {
        this.precedence = precedence;
    }

    public void print(){
        System.out.print(name+" "+"学校知名度:"+popularity+"☆ "+majority+" "+
                "专业热度:"+development+" ");
    }
}
public class lll {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        ArrayList<School> arrayList = new ArrayList<>();

        text();

        int count = 0;
        //---------------添加志愿处-----------------
        //添加志愿格式:
        // School school1 =new School("北京大学",5,"护理学",60);count++;


        School school1 = new School("北京大学", 5, "护理学", 60,5000);
        arrayList.add(school1);
        count++;

        School school2 = new School("北京大学", 5, "数学类", 88,50);
        count++;
        arrayList.add(school2);

        School school3 = new School("重庆大学", 4, "电气工程", 92,10000);
        count++;
        arrayList.add(school3);

        School school4 = new School("重庆大学", 4, "软件工程", 98,8000);
        count++;
        arrayList.add(school4);

        School school5 = new School("成都大学", 2, "计算机科学", 95,100000);
        count++;
        arrayList.add(school5);

        School school6 = new School("成都大学", 2, "土木工程", 72,100000);
        count++;
        arrayList.add(school6);
        //----------------------------------------

        System.out.println("请输入你分数对应的全省位次:");
        int number =scanner.nextInt();

        while (true) {
            System.out.println("");
            System.out.println("---------------------------");
            System.out.println("请选择查询服务:");
            System.out.println("1.根据学校知名度排名");
            System.out.println("2.根据专业热度排名");
            System.out.println("3.根据上岸概率排名");
            System.out.println("4.学校知名度和专业热度综合排序");
            System.out.println("5.退出");
            int choose = scanner.nextInt();
            System.out.println("");

            switch (choose) {
                case 1:
                    System.out.println("-------1.根据学校知名度排名---------");
                    getPopularity(arrayList,number);
                    continue;
                case 2:
                    System.out.println("-------2.根据专业热度排名---------");
                    getDevelopment(arrayList,number);
                    continue;
                case 3:
                    System.out.println("-------3.根据上岸概率排名---------");
                    getPercence(arrayList,number);
                    continue;
                case 4:
                    System.out.println("-------4.学校知名度和专业热度综合排序---------");
                    getComprehensive(arrayList,number);
                    continue;
                case 5:
                    System.exit(0);
                default:
                    System.out.println("输出有误!");
                    break;
            }

        }
    }

    private static void getComprehensive(ArrayList<School> arrayList, int number) {
     //综合排序
        Scanner scanner =new Scanner(System.in);
        int num;
        while (true) {
            System.out.println("请输入你希望院校知名度在排序中占比多少(1~10):");
             num = scanner.nextInt();
            if (num < 1 || num > 10) {
                System.out.println("输入有误!请重新输入!");
                continue;
            } else {
                break;
            }
        }

        for (int i =1;i<=arrayList.size()-1;i++){
            for (int j =0;j< arrayList.size()-i;j++){

                int a = arrayList.get(j).getPopularity()*2*num+ arrayList.get(j).getDevelopment()/10*(10-num);
                int b = arrayList.get(j+1).getPopularity()*2*num+ arrayList.get(j+1).getDevelopment()/10*(10-num);
                if (a<b){
                    School temp =new School();
                    temp = arrayList.get(j);
                    arrayList.set(j,arrayList.get(j+1));
                    arrayList.set(j+1,temp);
                }
            }
        }
        printList(arrayList,number);
    }

    private static void getPercence(ArrayList<School> arrayList, int number) {
        //上岸概率排序
        for (int i =1;i<=arrayList.size()-1;i++){
            for (int j =0;j< arrayList.size()-i;j++){

                if (arrayList.get(j).getPrecedence()<
                        arrayList.get(j+1).getPrecedence()){
                    School temp =new School();
                    temp = arrayList.get(j);
                    arrayList.set(j,arrayList.get(j+1));
                    arrayList.set(j+1,temp);
                }
            }
        }
        printList(arrayList,number);
    }

    private static void getDevelopment(ArrayList<School> arrayList,int number) {
        //专业排序
        for (int i =1;i<=arrayList.size()-1;i++){
            for (int j =0;j< arrayList.size()-i;j++){

                if (arrayList.get(j).getDevelopment()<
                        arrayList.get(j+1).getDevelopment()){
                    School temp =new School();
                    temp = arrayList.get(j);
                    arrayList.set(j,arrayList.get(j+1));
                    arrayList.set(j+1,temp);
                }
            }
        }
        printList(arrayList,number);
    }

    private static void getPopularity(ArrayList<School> arrayList,int number) {

        //知名度排序


       // System.out.println("----");
        for (int i =1;i<=arrayList.size()-1;i++){
            for (int j =0;j< arrayList.size()-i;j++){

                if (arrayList.get(j).getPopularity()<
                        arrayList.get(j+1).getPopularity()){
                    School temp =new School();
                    temp = arrayList.get(j);
                    arrayList.set(j,arrayList.get(j+1));
                    arrayList.set(j+1,temp);
                }
            }
        }
        printList(arrayList,number);


    }

    private static void printList(ArrayList<School> arrayList,int number) {
        //打印
        for (int i = 0;i<arrayList.size();i++){
            School school =arrayList.get(i);
            System.out.println((i+1)+":");
            school.print();
            int num =getPercent(school,number);
            System.out.println("上岸概率:"+num+"%");

        }
    }

    public static int getPercent(School school, int number){
        //计算上岸概率
       int presendence = school.getPrecedence();
       number = number-presendence;
       if (number<=0){
           return 100;
       }
       number=(number-number%1000)/100;
       if (number>100){
           return 0;
       }
       return 100-number;

    }

    public static void text(){
        System.out.println("————————我的志愿表————————");
        System.out.println("————————(排名不分先后)———————");
        System.out.println("北京大学 护理学 ");
        System.out.println("成都大学 土木工程");
        System.out.println("重庆大学 电气工程");
        System.out.println("重庆大学 软件工程");
        System.out.println("成都大学 计算机技术");
        System.out.println("北京大学 数学类");
        System.out.println("—————————————————————————");
        System.out.println();
    }
}

ce38ce64d0b64266ae87d8870444b345.png

 dff536e6f69347f99a8695a9d41ebd2f.png

 9c375006884b4154a99d1c5f5feb3afa.png

 9497a67aac504bcc880600a5cde97267.png2f9ba910172a4523953191c6b10af819.png

 a68fb3b16ebe4a1aa84d0d298936afec.png

 50e7d058b4c7489f824ad20bb6b23444.png

 e35c137424e945a7a82fbae12e7da5c6.png

 3d058cd541b148909e970fee8cff1fbd.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值