String[] words = new String[10]; String[] words = { "yes", "no" };
values[2] = values[1]; values.set(2, values.get(1));
Use hasNextDouble
public HomeworkScores(int maxScores) { System.out.println("enter socre 0 to quit: "); while(userInput.hasNextDouble()) { double nextScore = userInput.nextDouble(); socres[currentSize] = nextScore; currentSize++; } }
public double sumScores() { double sum = 0; for (double score: scores) { sum = sum + score; } return sum; }
output average score
public double averageScore() { if (currentSize == 0) { return 0; } else { sumScores() / currentSize; } }
remove lowest score
public void removeLowest() { double low = LowScore(); int lowScoreIndex = find(low); remove(lowScoreIndex); }
public void getLowScoreIndex()
{
double lowestScore = scores[0];
int lowestScoreIndex = 0;
for (int i = 1; i < currentSize; i++)
{
if (scores[i] < lowestScore)
{
lowestScore = scores[i];
lowestScoreIndex = i;
}
}
return lowestScoreIndex;
}
[/java]