I'm trying to learn Java on my own; however this book(for lack of a better word) sucks. It only has integer examples; therefore, I am unsure of how to script names, I'm trying "cha"; however it doesn't work. I want to write a program that reads: the total number of students, students name and score then outputs the students name with the highest score.
Here is what I have so far any assistance in helping me get on the right path would be appreciated.
public static void main(String[] args) {
int
// Prompt the user to enter the number of Students, Each Students Name and Score
String s1 = JOptionPane.showInputDialog(null,
"Enter the number of students",
"Example 32 Input", JOptionPane.QUESTION_MESSAGE);
int n1 = Integer.parseInt(s1);
String s2 = JOptionPane.showInputDialog(null,
"Enter the students score",
"Example 89 Input",
JOptionPane.QUESTION_MESSAGE);
int n2 = Integer.parseInt(s2);
String s3 = JOptionPane.showInputDialog(null, "Enter the students name",
"Example Shane, Kevin, Sara, Anna",
JOptionPane.QUESTION_MESSAGE);
int shs = 0;
while (s1 > 0) {
if (n2 > shs)
shs = n2;
s1 = s1 - 1;
JOptionPane.showMessageDialog(null, "The Student and High Score is " + shs,
"Example Shane 92", JOptionPane.INFORMATION_MESSAGE;
else exit;
}
}
}