Alright, so I'm trying to code a program that will have the user input a collection of names and scores and allow them to calculate the highest and second highest scores. The two main questions I have are as follows:
CODE:
package homework7;
import java.util.Scanner;
public class ScoreCalculator {
public static void main(String[] args) {
int i = 0;
Scanner keyboard = new Scanner(System.in);
System.out.print("Please enter the number of students: ");
int count = keyboard.nextInt();
keyboard.nextLine();
do {
i++;
System.out.print("Please enter score number " + i + ": ");
int score = keyboard.nextInt();
keyboard.nextLine();
} while (i <= count);
}
}
- How can I change it to "Please enter name and score number" in the do loop and still extract only the int value despite the fact that a String is also being entered?
- How can I store each int the user inputs into a separate variable within the do loop, and then extract those values and use them at the end to calculate the two highest scores?
Please keep it simple - this is for a class and we aren't very in depth yet. That means no arrays, no separate classes, no files or lists.