問(wèn)題描述
某校的慣例是在每學(xué)期的期末考試之后發(fā)放獎(jiǎng)學(xué)金。發(fā)放的獎(jiǎng)學(xué)金共有五種,獲取的條件各自不同:
院士獎(jiǎng)學(xué)金,每人8000元,期末平均成績(jī)高于80分(>80),并且在本學(xué)期內(nèi)發(fā)表1篇或1篇以上論文的學(xué)生均可獲得;
五四獎(jiǎng)學(xué)金,每人4000元,期末平均成績(jī)高于85分(>85),并且班級(jí)評(píng)議成績(jī)高于80分(>80)的學(xué)生均可獲得;
成績(jī)優(yōu)秀獎(jiǎng),每人2000元,期末平均成績(jī)高于90分(>90)的學(xué)生均可獲得;
西部獎(jiǎng)學(xué)金,每人1000元,期末平均成績(jī)高于85分(>85)的西部省份學(xué)生均可獲得;
班級(jí)貢獻(xiàn)獎(jiǎng),每人850元,班級(jí)評(píng)議成績(jī)高于80分(>80)的學(xué)生干部均可獲得;
只要符合條件就可以得獎(jiǎng),每項(xiàng)獎(jiǎng)學(xué)金的獲獎(jiǎng)人數(shù)沒(méi)有限制,每名學(xué)生也可以同時(shí)獲得多項(xiàng)獎(jiǎng)學(xué)金。例如姚林的期末平均成績(jī)是87分,班級(jí)評(píng)議成績(jī)82分,同時(shí)他還是一位學(xué)生干部,那么他可以同時(shí)獲得五四獎(jiǎng)學(xué)金和班級(jí)貢獻(xiàn)獎(jiǎng),獎(jiǎng)金總數(shù)是4850元。
基本要求
現(xiàn)在給出若干學(xué)生的相關(guān)數(shù)據(jù),請(qǐng)計(jì)算哪些同學(xué)獲得的獎(jiǎng)金總數(shù)最高(假設(shè)總有同學(xué)能滿足獲得獎(jiǎng)學(xué)金的條件)。
輸入數(shù)據(jù)格式格式:
輸入的第一行是一個(gè)整數(shù)N(1 <= N <= 100),表示學(xué)生的總數(shù)。接下來(lái)的N行每行是一位學(xué)生的數(shù)據(jù),從左向右依次是姓名,期末平均成績(jī),班級(jí)評(píng)議成績(jī),是否是學(xué)生干部,是否是西部省份學(xué)生,以及發(fā)表的論文數(shù)。姓名是由大小寫英文字母組成的長(zhǎng)度不超過(guò)20的字符串(不含空格);期末平均成績(jī)和班級(jí)評(píng)議成績(jī)都是0到100之間的整數(shù)(包括0和100);是否是學(xué)生干部和是否是西部省份學(xué)生分別用一個(gè)字符表示,Y表示是,N表示不是;發(fā)表的論文數(shù)是0到10的整數(shù)(包括0和10)。每?jī)蓚€(gè)相鄰數(shù)據(jù)項(xiàng)之間用一個(gè)空格分隔。
輸出數(shù)據(jù)格式:
輸出包括三行,第一行是獲得最多獎(jiǎng)金的學(xué)生的姓名,第二行是這名學(xué)生獲得的獎(jiǎng)金總數(shù)。如果有兩位或兩位以上的學(xué)生獲得的獎(jiǎng)金最多,輸出他們之中在輸入文件中出現(xiàn)最早的學(xué)生的姓名。第三行是這N個(gè)學(xué)生獲得的獎(jiǎng)學(xué)金的總數(shù)。
輸入
4
YaoLin 87 82 Y N 0
ChenRuiyi 88 78 N Y 1
LiXin 92 88 N N 0
ZhangQin 83 87 Y N 1
輸出
ChenRuiyi
9000
28700
學(xué)生類
public class students {
private String name;
private int avgScore;
private int classScore;
private String crdres;
private String westStudent;
private int writes;
public String name() {
char[] words = name.toCharArray();
if (words.length > 20) {
} else {
for (int i = 0; i < words.length; i++) {
if (words[i] >= 48 && words[i] <= 97) {
}
}
}
return name;
}
public int avgScore() {
if (avgScore > 100 || avgScore < 0) {
}
return avgScore;
}
public int classScore() {
if (classScore > 100 || classScore < 0) {
}
return classScore;
}
public String westStudent()
{
if(!westStudent.equals("Y") || !westStudent.equals("N"))
{
}
return westStudent;
}
public String crdres()
{
if(!crdres.equals("Y") || !crdres.equals("N"))
{
}
return crdres;
}
public int writes() {
if (writes > 10 || writes < 0) {
}
return writes;
}
public int yaunshi(String name,int avgScore,int writes)
{
if(avgScore > 80 && writes >=1) {
return 8000;
}
return 0;
}
public int wusi(String name,int avgScore,int classScore)
{
if(avgScore > 85 && classScore > 80)
{
return 4000;
}
return 0;
}
public int chengji(String name,int avgScore)
{
if(avgScore >90)
{
return 2000;
}
return 0;
}
public int west(String name,int avgScore,String westStudent)
{
if(avgScore > 85 && westStudent.equals("Y"))
{
return 1000;
}
return 0;
}
public int classmoney(String name,int classScore,String crdres)
{
if(classScore > 80 && crdres.equals("Y"))
{
return 850;
}
return 0;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAvgScore() {
return avgScore;
}
public void setAvgScore(int avgScore) {
this.avgScore = avgScore;
}
public int getClassScore() {
return classScore;
}
public void setClassScore(int classScore) {
this.classScore = classScore;
}
public String getCrdres() {
return crdres;
}
public void setCrdres(String crdres) {
this.crdres = crdres;
}
public String getWestStudent() {
return westStudent;
}
public void setWestStudent(String westStudent) {
this.westStudent = westStudent;
}
public int getWrites() {
return writes;
}
public void setWrites(int writes) {
this.writes = writes;
}
}
主函數(shù)
public class test {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("請(qǐng)輸入學(xué)生總數(shù)");
int num = sc.nextInt();
System.out.println("請(qǐng)輸入學(xué)生姓名,學(xué)生期末平均成績(jī),班級(jí)評(píng)議成績(jī),是否是學(xué)生干部,是否是西部省份的學(xué)生,發(fā)表的論文數(shù)");
int max = 0;
int count = 0;
String name = "";
for(int i = 0; i <num ;i++) {
String names = sc.next();
int avgscore = sc.nextInt();
int classscore = sc.nextInt();
String crades = sc.next();
String weststudent = sc.next();
int writes = sc.nextInt();
students student = new students();
int yuanshi = student.yaunshi(names,avgscore,writes);
int wusi = student.wusi(names,avgscore,classscore);
int score = student.chengji(names,avgscore);
int west = student.west(names,avgscore,weststudent);
int classs = student.classmoney(names,classscore,crades);
int total = yuanshi + wusi + score + west + classs;
if(total > max)
{
max = total;
name = names;
}
else
{
max = max;
}
count = count + total;
}
System.out.println(name);
System.out.println(max);
System.out.println(count);
}