1. 程式人生 > >Java語言程式設計(基礎篇)第十版 5.8

Java語言程式設計(基礎篇)第十版 5.8


public class J5_8 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		java.util.Scanner input = new java.util.Scanner(System.in);
		System.out.print("Enter the number of students: ");
		
		int student = input.nextInt();
		String name = "ABC";
		double score = 0;
		for(int i = 0;i<student;i++)
		{
			System.out.print("input the "+i+"Student information: ");
			double scores = input.nextDouble();
			String names = input.nextLine();
			
			if(scores >score) {
				score = scores;
				name  = names;
			}
			
		}
		System.out.println("The higly score Student is: "+name+"  score is "+score);
		
	}

}