HW4.9

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的更多相关文章
- HW4.46
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW4.45
public class Solution { public static void main(String[] args) { int count = 0; for(int i = 1; i < ...
- HW4.44
public class Solution { public static void main(String[] args) { double randX; double randY; int hit ...
- HW4.43
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW4.42
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW4.41
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW4.40
public class Solution { public static void main(String[] args) { long positiveSide = 0; long negativ ...
- HW4.39
public class Solution { public static void main(String[] args) { double sum; double baseSalary = 500 ...
- HW4.38
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- HW4.37
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
随机推荐
- 使用pdb调试python
python pdb调试 python -m pdb myscript.py #注意这会重启myscript.py,这样启动的话,代码每一行都是一个节点 也可以在程序中这么设置断点: import p ...
- C#运算符之与,或,异或及移位运算
C#运算符之与,或,异或及移位运算 1.剖析异或运算(^) 二元 ^ 运算符是为整型和 bool 类型预定义的.对于整型,^ 将计算操作数的按位“异或”.对于 bool 操作数,^ 将计算操作数的逻辑 ...
- STM32的FSMC总线驱动ili9341,掉电重启无法正常显示的问题
问题描述 通过STM32的FSMC总线驱动ili9341,程序调试和刚下载的时候,显示完全正常.可是就在我掉电关机,重新启动的时候就完全跑飞了.这令我非常疑惑.以下是我的FSMC总线配置程序, sta ...
- proteus画元件
一.元件概述 使用过“protel DXP”画元件的人想必对一个元件的构成已经非常清楚了.一个完整的元件包括如下几个部分: 元件 = 原理图元件模型 + PCB封装模型 + 电路仿真特性 1.原理图元 ...
- SDC(4)–set_clock_groups 与–add选项
1,set_clock_groups -exclusive 有多个时钟,但是多个时钟不会同时生效 例如: 2,-add 只有一个时钟输入源,但是始终的频率等可能变 例如:
- loadmore & scroll
loadmore <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.m ...
- SpringMVC可以配置多个拦截后缀*.html和.do等
一个servlet可以配置多个servlet-mapping, 因此在xml文件中我们可以这样配置: <!-- springmvc配置 --> <servlet> <se ...
- Yorhom浅谈:作为一名初中生,自学编程的点点滴滴 - Yorhom's Game Box
Yorhom浅谈:作为一名初中生,自学编程的点点滴滴 我是一名不折不扣的初中生,白天要背着书包去上学,晚上要拿起笔写作业.天天如此,年年如此. 我的爱好很广泛,喜欢了解历史,读侦探小说,骑车,打篮球, ...
- YIi 权限管理和基于角色的访问控制
验证和授权(Authentication and Authorization) 定义身份类 (Defining Identity Class) 登录和注销(Login and Logout) 访问控制 ...
- 正确使用c语言中的头文件
我们在使用c编程的时候经常会遇到头文件,前段时间我自己做了个小项目的时候,也遇到了关于头文件的问题. 预处理器发现#include 指令后,就会寻找后跟的文件名并把这个文件包含的内容包含到当前文件中. ...