✔ 最佳答案
a)
String[] contestantNames = new String[NO_CONTESTANTS];
double[] contestantScores = new double[NO_CONTESTANTS];
b)
//for each of the 5 contestant, get the name and score and put into the 2 arrays
for (int i=0; i<NO_CONTESTANTS; i++)
{
System.out.print( "Enter name of Contestant No " + (i+1) + ": " );
contestantNames[i] = stdin.readLine();
System.out.print( "Enter score of Contestant No " + (i+1) + ": " );
contestantScores[i] = Double.parseDouble(stdin.readLine());
}
c)
//default the lowest score and lowest index to be the first contestant
//then scan the rest of the contestants
//if any of them have a lower score, assign their index as the lowest
//after the for loop is over, the lowest score and index is found
//the name at the index is the name of the contestant to be eliminated
double lowestScore = contestantScores[0];
int lowestIndex = 0;
for (int i=1; i<NO_CONTESTANTS; i++)
{
if (contestantScores[i] < lowestScore)
{
lowestIndex = i;
lowestScore = contestantScores[i];
}
}
System.out.println( "Contestant " + contestantNames[lowestIndex] + " has the lowest score of " + lowestScore + " and is eliminated. " );