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 ...
随机推荐
- Python设计模式——设计原则
1.单一职责原则:每个类都只有一个职责,修改一个类的理由只有一个 2.开放-封闭远程(OCP):开放是指可拓展性好,封闭是指一旦一个类写好了,就尽量不要修改里面的代码,通过拓展(继承,重写等)来使旧的 ...
- AWR报告导出的过程报ORA-06550异常
刚才在笔记本上(win 7)想要导出一套RAC的AWR报告(linux),执行awrgrpt.sql的脚本的过程中报错了,报错的异常代码是:ORA-06550.经过检查,发现是用户的问题,换成sys用 ...
- C和BlockCode
在使用code block的时候,需要先build,然后再run,否则run的还是上次编译的内容.
- String类中常用的操作
一.获取: 1.获取字符串的长度(注意是方法,不是跟数组的属性一样的) int length(); 1 public static void getLength(){ 2 String s = &qu ...
- Hadoop集群(第5期)_Hadoop安装配置
1.1 Hadoop简介 Hadoop是Apache软件基金会旗下的一个开源分布式计算平台.以Hadoop分布式文件系统(HDFS,Hadoop Distributed Filesystem)和Map ...
- oracle----删除数据
1. 删除数据:delete语句: 语法: DELETE FROM table_name; (1),无条件删除: SQL> create table testdel as select * fr ...
- 分别取商和余数:divmod(a, b)
使用函数:divmod(a, b)可以实现分别取商和余数的操作: >>> divmod(123,3) (41, 0) >>> divmod(200,6) (33, ...
- php和.net的DES加密解密方法
.net版本 /// <summary> /// DES加密 /// </summary> /// <param name="pToEncrypt"& ...
- 汇编 db,dw,dd的区别
db定义字节类型变量,一个字节数据占1个字节单元,读完一个,偏移量加1 dw定义字类型变量,一个字数据占2个字节单元,读完一个,偏移量加2 dd定义双字类型变量,一个双字数据占4个字节单元,读完一个, ...
- 浅谈HTTP中Get与Post的区别/HTTP协议与HTML表单(再谈GET与POST的区别)
HTTP协议与HTML表单(再谈GET与POST的区别) GET方式在request-line中传送数据:POST方式在request-line及request-body中均可以传送数据. http: ...