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("請輸入學生總數(shù)數(shù)");
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;
}
}
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。