标签:
1 import java.util.Scanner; 2 3 public class Solution 4 { 5 public static void main(String[] args) 6 { 7 Scanner input = new Scanner(System.in); 8 9 System.out.print("Enter the number of students: "); 10 int numberOfStudents = input.nextInt(); 11 12 int score = 0; 13 int max = 0; 14 String student = ""; 15 String maxStudent = ""; 16 17 for(int i = 0; i < numberOfStudents; i++) 18 { 19 System.out.print("Enter a student‘s name: "); 20 student = input.next(); 21 22 System.out.print("Enter his score: "); 23 score = input.nextInt(); 24 25 if(score > max) 26 { 27 max = score; 28 maxStudent = student; 29 } 30 } 31 32 input.close(); 33 34 System.out.println("The one has best score is " + maxStudent + ", his score is " + max); 35 } 36 }
标签:
原文地址:http://www.cnblogs.com/wood-python/p/5769945.html