- 谁拿了最多奖学金
- 2014-11-16 04:42:50 @
代码
import java.util.Scanner;
import java.lang.String;
class Test {
public static void main (String[] args)
{
Test test = new Test();
test.go();
}
public void go(){
int totalStudent;
int i = 0;
int position = 0;// position of student with largest money
int totalM = 0; //total money
int largestM = 0; //money of largest student
Scanner in = new Scanner(System.in);
totalStudent = in.nextInt();
Student[] allStudent = new Student[totalStudent];
while (i<totalStudent)
{
allStudent[i] = new Student (0,in.next(),in.nextInt(),in.nextInt(),in.next().charAt(0),in.next().charAt(0),in.nextInt());
i++;
}
in.close();
for (int j=0;j<totalStudent;j++){
int M = allStudent[j].calculate();
totalM += M;
if (M>largestM)
{
position = j;
largestM = M;
}
}
System.out.println(allStudent[position].name);
System.out.println(largestM);
System.out.println(totalM);
}
class Student {
int total;
String name;
int score1;
int score2;
char leader;
char west;
int paper;
Student (int total, String name, int score1, int score2, char leader, char west, int paper){
this.total = total;
this.name = name;
this.score1 = score1;
this.score2 = score2;
this.leader = leader;
this.west = west;
this.paper = paper;
}
public int calculate(){
total = 0;
if (score1>80 && paper>=1)
total += 8000;
if (score1>85 && score2>80)
total += 4000;
if (score1>90)
total += 2000;
if (score1>85 && west == 'Y')
total += 1000;
if (score2>80 && leader == 'Y')
total += 850;
return total;
}
public String toString()
{
return name + " " + score1 + " " + score2 + " " + leader +" "+ west+" " + paper;
}
}
}
1 条评论
-
twd2 LV 9 MOD @ 2014-11-17 20:40:22
类名要是Main
不好意思 回复迟了
- 1