1 import java.util.Scanner;
2 /**
3 * @author 冰樱梦
4 * 时间:2018年下半年
5 * 题目:找出分数最高的前两个学生
6 *
7 */
8 public class Exercise05_09 {
9 public static void main(String[] args){
10 String name,first = null,second = null;
11 Scanner input=new Scanner(System.in);
12 double score;
13 double max=0,sec=0;
14 System.out.println("输入学生的个数");
15 int number=input.nextInt();
16 for(int i=0;i<number;i++){
17 System.out.println("输入学生的名字");
18 name=input.next();
19 System.out.println("输入学生的分数");
20 score=input.nextDouble();
21
22 if(score>max){
23 first=name;
24 max=score;
25 }
26 else if(score>sec){
27 second=name;
28 sec=score;
29 }
30 }
31 System.out.printf("%s\n%s\n", first,second);
32 }
33 }