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.print("Enter student numbers:"); int number=input.nextInt(); String []student=new String[number]; double []score=new double[number]; double max1=0,max2=0; int index1=0,index2=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>max1&&score>max2){ max1=score; index1=i; }else if(score<max1&&score>max2){ max2=score; index2=i; } } System.out.println("The max score name is "+student[index1]+" score is "+score[index1]+" The second score name is "+student[index2]+" score is "+score[index2]); } }
|