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