码迷,mamicode.com
首页 > 其他好文 > 详细

HW4.8

时间:2016-08-14 12:59:40      阅读:125      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

 

 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 }

 

HW4.8

标签:

原文地址:http://www.cnblogs.com/wood-python/p/5769945.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!