public class Test { public static void main(String[] args){ //程序说明:找出分数最高的学生 //提示用户输入 System.out.print("Enter the number of students:"); Scanner input = new Scanner(System.in); int n = input.nextInt(); String str = "",strh = "",strs = ""; double score = 0,high = 0,second = 0; //输入学生信息 int i = 1; while(i <= n) { System.out.print("Enter the name of the student:"); str = input.next(); System.out.print("Enter the score of the student:"); score = input.nextDouble(); if(score > high) { second = high; strs = strh; high = score; strh = str; } else if(score > second) { second = score; strs = str; } i++; } //显示分数最高的学生 System.out.println("name of the top student:" + strh + "."+ "score of the top student:" + high); System.out.println("name of the second student:" + strs + "."+ "score of the second student:" + second); } }