package nameyu; import java.util.Scanner; public class Test { /** * @param args */ public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.println("Enter student numbers:"); int number=input.nextInt();//学生的个数 String []student=new String[number];//存放学生的姓名 double []score=new double [number];//存放学生的分数 double max=0;//最高分 int index=0;//下标 for(int i=0;i<number;i++){ System.out.print("Enter student name:"); student=input.next(); System.out.print("Enter student score:"); score=input.nextDouble(); if(score>max){ max=score; index=i; } } System.out.println("The max score is "+score[index]+" The name is "+student[index]); } }
|