-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExercise05_08.java
More file actions
42 lines (35 loc) · 1.18 KB
/
Copy pathExercise05_08.java
File metadata and controls
42 lines (35 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package Chapter5;
import java.util.Scanner;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author jorda
*/
public class Exercise05_08 {
public static void main(String[] args){
Scanner NumberInput = new Scanner(System.in);
Scanner NameInput = new Scanner(System.in);
System.out.print("Enter the number of students: ");
int iNumStudents = NumberInput.nextInt();
String sName;
double dScore;
double dHighScore = 0;
String sHighScore = "No data";
for (int i = 0; i < iNumStudents; i++) {
System.out.print("Enter a student name: ");
sName = NameInput.next();
System.out.print("Enter a student score: ");
dScore = NumberInput.nextDouble();
if (dScore > dHighScore){
sHighScore = sName;
dHighScore = dScore;
}
}
System.out.println("");
System.out.println("Top student is " + sHighScore + " with a score of " + dHighScore);
}
}