java实现找出两个分数最高的学生程序源码
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; double []score=new double; 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+" score is "+score+" The second score name is "+student+" score is "+score); } }
页:
[1]