一、题目链接
http://noi.openjudge.cn/ch0109/04/
二、解题思路
三、实施步骤
四、Java程序
import java.util.Scanner;
class Student {
private String name;
private int score;
private int vote;
private char cadre;
private char west;
private int paper;
private int scholarship;
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 getVote() {
return vote;
}
public void setVote(int vote) {
this.vote = vote;
}
public char getCadre() {
return cadre;
}
public void setCadre(char cadre) {
this.cadre = cadre;
}
public char getWest() {
return west;
}
public void setWest(char west) {
this.west = west;
}
public int getPaper() {
return paper;
}
public void setPaper(int paper) {
this.paper = paper;
}
public int getScholarship() {
return scholarship;
}
public void setScholarship(int scholarship) {
this.scholarship = scholarship;
}
}
public class Main {
public Student maxScholarship(Student[] students) {
int n = students.length;
int max;
int index;
int scholarship;
for (Student student : students) {
scholarship = 0;
if (student.getScore() > 80 && student.getPaper() >= 1) {
scholarship = scholarship + 8000;
}
if (student.getScore() > 85 && student.getVote() > 80) {
scholarship = scholarship + 4000;
}
if (student.getScore() > 90) {
scholarship = scholarship + 2000;
}
if (student.getScore() > 85 && student.getWest() == 'Y') {
scholarship = scholarship + 1000;
}
if (student.getVote() > 80 && student.getCadre() == 'Y') {
scholarship = scholarship + 850;
}
student.setScholarship(scholarship);
}
max = students[0].getScholarship();
index = 0;
for (int i = 1; i < n; i++) {
if (students[i].getScholarship() > max) {
max = students[i].getScholarship();
index = i;
}
}
return students[index];
}
public int totalScholarship(Student[] students) {
int ans = 0;
for (Student t : students) {
ans = ans + t.getScholarship();
}
return ans;
}
public static void main(String[] args) {
Main test = new Main();
Scanner input = new Scanner(System.in);
int N = input.nextInt();
Student[] students = new Student[N];
for (int i = 0; i < N; i++) {
students[i] = new Student();
students[i].setName(input.next());
students[i].setScore(input.nextInt());
students[i].setVote(input.nextInt());
students[i].setCadre(input.next().charAt(0));
students[i].setWest(input.next().charAt(0));
students[i].setPaper(input.nextInt());
}
Student ans = test.maxScholarship(students);
System.out.println(ans.getName());
System.out.println(ans.getScholarship());
System.out.print(test.totalScholarship(students));
}
}