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;
         int secondMax = 0;
         String student = "";
         String maxStudent = "";
         String secondMaxStudent = "";

         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)
             {
                 secondMax = max;
                 secondMaxStudent = maxStudent;
                 max = score;
                 maxStudent = student;

             }
         }

         input.close();

         System.out.println("The one has best score is " + maxStudent + ", his score is " + max);
         System.out.println("The one has second score is " + secondMaxStudent + ", his score is " + secondMax);
     }
 }

HW4.9的更多相关文章

  1. HW4.46

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  2. HW4.45

    public class Solution { public static void main(String[] args) { int count = 0; for(int i = 1; i < ...

  3. HW4.44

    public class Solution { public static void main(String[] args) { double randX; double randY; int hit ...

  4. HW4.43

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  5. HW4.42

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  6. HW4.41

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  7. HW4.40

    public class Solution { public static void main(String[] args) { long positiveSide = 0; long negativ ...

  8. HW4.39

    public class Solution { public static void main(String[] args) { double sum; double baseSalary = 500 ...

  9. HW4.38

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

  10. HW4.37

    import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...

随机推荐

  1. CentOS添加RPMforge软件源

    1.查看CentOS版本 cat /etc/redhat-release 2.查看系统位数 uname -i 3.下载rpm包 wget "rpm地址" CentOS 6: i68 ...

  2. hdu 2243 考研路茫茫——单词情结 ac自动机+矩阵快速幂

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=2243 题意:给定N(1<= N < 6)个长度不超过5的词根,问长度不超过L(L <23 ...

  3. 用Cocos2d-x实现2D光线效果

    2015.3.23优化修改,现在已经能达到稳定60帧了.. 本博客地址:http://www.cnblogs.com/wolfred7464/ 创意来自于:http://ncase.me/sight- ...

  4. Spring核心框架 - AOP之动态代理机制

    动态代理类的字节码在程序运行时由Java反射机制动态生成,无需程序员手工编写它的源代码.动态代理类不仅简化了编程工作,而且提高了软件系统的可扩展性,因为Java 反射机制可以生成任意类型的动态代理类. ...

  5. ios字符串操作

    string的操作应用 NSRange range = [self.general rangeOfString:@"."]; NSString *str = [self.gener ...

  6. MySQL 5.7 启用查询日志

    MySQL版本:5.7 新版本的 my.ini 文件改动了,导致原先启用查询日志的方法不再适用 新版本的启用方法如下: 1. 修改 C:\ProgramData\MySQL\MySQL Server ...

  7. poj 1631 Bridging signals (二分||DP||最长递增子序列)

    Bridging signals Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 9234   Accepted: 5037 ...

  8. Mac下无法推出硬盘

    Q:刚刚mac使用移动硬盘,使用后推出时弹出无法推出,提示:Finder正在使用中. 解决:打开#活动监视器#(找不到可以在spotlight中搜索),找到Finder应用,双击,强制退出后再启动Fi ...

  9. 不实名认证去除新浪云SEA的实名认证提示的方法

    最近在做个人空间,不想搭本地php和数据库,为了省事,在新浪云SEA开了个php应用,挺好用的,现在没什么访问量,基本不收费,特别适合练手. 我的空间是php,由于没有实名验证,每个页面都会出现一个 ...

  10. location.hash 详解

    前年9月twitter改版. 一个显著变化,就是URL加入了"#!"符号.比如,改版前的用户主页网址为 http://twitter.com/username 改版后,就变成了 h ...