Java Reference
In-Depth Information
25. If the array indices are out of bounds, then Java will halt the program with an error
message, so no other checks on the parameters are needed.
/**
Changes the grade for student number studentNumber on quiz number
quizNumber to newGrade.
*/
public void changeGrade( int studentNumber,
int quizNumber, int newGrade)
{
grade[studentNumber][quizNumber] = newGrade;
}
26. /**
Returns an array with the average quiz score for each student.
*/
public double [] getStudentAverages( )
{
int arraySize = studentAverage.length;
double [] temp = new double [arraySize];
for ( int i = 0; i < arraySize; i++)
temp[i] = studentAverage[i];
return temp;
}
27. /**
Returns an array with the average score for each quiz.
*/
public double [] getQuizAverages( )
{
int arraySize = quizAverage.length;
double [] temp = new double [arraySize];
for ( int i = 0; i < arraySize; i++)
temp[i] = quizAverage[i];
return temp;
}
Programming Projects
Visit www.myprogramminglab.com to complete select exercises online and get instant
feedback.
1. In the sport of diving, seven judges award a score between 0 and 10, where each
score may be a floating-point value. The highest and lowest scores are thrown
out and the remaining scores are added together. The sum is then multiplied by
the degree of difficulty for that dive. The degree of difficulty ranges from 1.2 to
3.8 points. The total is then multiplied by 0.6 to determine the diver's score.
 
Search WWH ::




Custom Search