public static void main(String[] args)
{
intro();
int numberOfStudents = 0;
boolean succeded;
do
{
succeded = true;
String response =
JOptionPane.showInputDialog("Enter number of students.");
try
{
numberOfStudents = Integer.parseInt(response);
}
catch(NumberFormatException e)
{
JOptionPane.showMessageDialog(null, "NFE: " + e.getMessage());
succeded = false;
}
}
while(!succeded);
String[] names = new String[numberOfStudents];
...
public static void getInput(String[] names, int[] scores)
{
...
String s =
JOptionPane.showInputDialog("What is the students name?");
names[count] = s;
s = JOptionPane.showInputDialog("Please enter a number.");
// You can do the same here as above: guard this parseInt
// method call with a try/catch statemnt and JOptioPane
// notification. Incrementing the "count" variable may
// need some attention/help.
scores[count] = Integer.parseInt(s);
}
while(count++ < names.length-1);
}