您的位置:首页 > 其它

NYOJ--60-题目-------------------------------谁获得了最高奖学金

2015-03-09 20:35 489 查看
package org.acm.newhand;

/*http://acm.nyist.net/JudgeOnline/problem.php?pid=60*/

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class NYOJ_60 {

// 学生类
public static class Student {
public String name, stulead, weststu;
public int tg, cg, thesis;
public int sum;

public Student() {
}

public Student(String name, int tg, int cg, String stulead, String weststu, int thesis) {
this.name = name;
this.tg = tg;
this.cg = cg;
this.stulead = stulead;
this.weststu = weststu;
this.thesis = thesis;
}
}

private static Student[] stus = new Student[101];// 学生数组
private static int x;

public static void main(String[] args) throws IOException {

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

int T = Integer.parseInt(br.readLine());
while (T-- > 0) {

Arrays.fill(stus, new Student());

x = Integer.parseInt(br.readLine());
String studata[];
for (int i = 1; i <= x; i++) {
studata = br.readLine().split(" ");
stus[i] = new Student(studata[0], Integer.parseInt(studata[1]), Integer.parseInt(studata[2]), studata[3],
studata[4], Integer.parseInt(studata[5]));
}
compare(stus);
}
}

// 评比奖学金
private static void compare(Student stus[]) {

int max = 0, sum = 0;
String who_getmaxmoney_name = "";
for (int i = 1; i <= x; i++) {
// 院士奖学金
if (stus[i].tg > 80 && stus[i].thesis >= 1)
stus[i].sum += 8000;
// 五四奖学金
if (stus[i].tg > 85 && stus[i].cg > 80)
stus[i].sum += 4000;
// 成绩优秀奖
if (stus[i].tg > 90)
stus[i].sum += 2000;
// 西部奖学金
if (stus[i].tg > 85 && stus[i].weststu.equals("Y"))
stus[i].sum += 1000;
// 班级贡献奖
if (stus[i].cg > 80 && stus[i].stulead.equals("Y"))
stus[i].sum += 850;

// 找出拿钱最多的童鞋
if (stus[i].sum > max) {
max = stus[i].sum;
who_getmaxmoney_name = stus[i].name;
}
sum += stus[i].sum;
}
System.out.println(who_getmaxmoney_name);
System.out.println(max);
System.out.println(sum);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息