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 ...
随机推荐
- Visual Studio 2010 旗舰版安装图解
微软发布了最新的 Visual Studio 2010 软件开发编程平台及 .Net Framework 4 框架.这次 VisualStudio 2010 包括 Professional 专业版.P ...
- 换一换js
(function(){ var tit = $("#changes"), con = $("#wday>ul"), page = con.length, ...
- hdu 1423
最长公共上升子序列:O(n*m)的算法: #include<cstdio> #include<cstring> #define maxn 1000 using namespac ...
- PIL(Python Image Library)生成验证码
# -*- coding: utf-8 -*-#导入三个模块import Image,ImageDraw,ImageFontimport randomimport math'''基本功能'''#图片宽 ...
- 中国海洋大学第四届朗讯杯高级组 I Cuckoo for Hashing
http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=2719&cid=1203 题意 :意思就是哈希来的,具体大意就是说有两个哈希表,然后有这样 ...
- C语言中随机数的生成
刚好在找这方面的资料,看到了一片不错的,就全文转过来了,省的我以后再找找不到. 在C语言中,可以通过rand函数得到一个“伪随机数”.这个数是一个整数,其值大于等于0且小于等于RAND_MAX.ran ...
- POJ 2492 A Bug's Life(并查集)
http://poj.org/problem?id=2492 题意 :就是给你n条虫子,m对关系,每一对关系的双方都是异性的,让你找出有没有是同性恋的. 思路 :这个题跟POJ1703其实差不多,也是 ...
- Android网络请求心路历程
HTTP请求&响应 既然说从入门级开始就说说Http请求包的结构.一次请求就是向目标服务器发送一串文本.什么样的文本?有下面结构的文本.HTTP请求包结构 例子: 1 2 3 4 5 6 7 ...
- Dojo Widget系统(转)
Dojo 里所有的小部件(Widget)都会直接或间接的继承 dijit._Widget / dijit._WidgetBase dijit._Widget 是 dojo 1.6 和 1.6之前的版本 ...
- C 语言函数指针
c代码: #include <stdio.h> int add(int x,int y); int subtract(int x,int y); int domath(int (*math ...