write a program that promps the user to enter the number of studenst up tp 3 students , the students name and scores, finally dysplays the student with the highest score
CODE
public static void main(String[] args) {
// 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 + s3,
"Example Shane 92", JOptionPane.INFORMATION_MESSAGE);
}
}
*edit: code tags
This post has been edited by PennyBoki: 16 Sep, 2007 - 01:53 PM