HW4.8

HW4.8

 import java.util.Scanner;

 public class Solution
 {
     public static void main(String[] args)
     {
         Scanner input = new Scanner(System.in);

         System.out.print("Enter the number of students: ");
         int numberOfStudents = input.nextInt();

         int score = 0;
         int max = 0;
         String student = "";
         String maxStudent = "";

         for(int i = 0; i < numberOfStudents; i++)
         {
             System.out.print("Enter a student's name: ");
             student = input.next();

             System.out.print("Enter his score: ");
             score = input.nextInt();

             if(score > max)
             {
                 max = score;
                 maxStudent = student;
             }
         }

         input.close();

         System.out.println("The one has best score is " + maxStudent + ", his score is " + max);
     }
 }
上一篇:fullcalender


下一篇:POJ 2139 Six Degrees of Cowvin Bacon (floyd)