subject

Assume that two arrays are used to store information about students’ grades. One array contains the students' numerical scores (integers in the range 0 …100). The other array contains the corresponding letter grades (Strings having possible values of "A", "B", "C", "D", and "F"). For example, if studentScores[0] contains 92, then studentLetters[0] will contain the corresponding letter grade for 92, which is "A" if the professor is using a standard grading scale. Note that the professor might choose a different grading scale, so if one is looking for A grades, one should look in the studentLetters array for values of "A", and not in the studentScores array for values of 90 and above.

public class Gradebook
{

private int[] studentScores;

private String[] studentLetters;

// postcondition: returns -1.0 if letterGrade does not appear in studentLetters

// otherwise, returns average of all studentScores[n],

// for all 0 <= n < studentScores. length, such that

// studentLetters[n] is equal to letterGrade

public double letterAverage(String letterGrade)

{

}

}

Write the method letterAverage. This method returns a double representing the average (arithmetic mean) of the student scores that correspond to a given letter grade. LetterAverage returns -1.0 if none of the student scores corresponds to the given letter grade.

For example, given the following arrays:
studentScores: 96 72 84 65 89 60 78 86 75 61 85
studentLetters: A C B D A D B B C D B
letterAverage("B") would return the number 83.25, which is the average of the four scores that correspond to the letter grade B.
letterAverage("A") would return the number 92.5, which is the average of the four scores that correspond to the letter grade A.
letterAverage("F") would return -1.0, because no scores are below 60.
Note that the professor might choose a different grading scale, so if one is looking for A grades, one should look in the studentLetters array for values of "A", and not in the studentScores array for values of 90 and above.
Complete method letterAverage below:

// postcondition: returns -1.0 if letterGrade does not appear in studentLetters

// otherwise, returns average of all studentScores[n],

// for all 0 <= n < studentScores. length, such that

// studentLetters[n] is equal to letterGrade

public double letterAverage(String letterGrade)

{

}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 08:30
Active listen eliminates barries to communication true or false
Answers: 1
question
Computers and Technology, 23.06.2019 02:30
Three out of five seniors remain undecided about a college major at the end of their senior year.
Answers: 3
question
Computers and Technology, 23.06.2019 20:30
If chris has a car liability insurance, what damage would he be covered for
Answers: 1
question
Computers and Technology, 23.06.2019 23:30
The keyboard usually has six rows of keys. which of the following is not one of the key group categories? letter keys number keys control keys graphic keys
Answers: 1
You know the right answer?
Assume that two arrays are used to store information about students’ grades. One array contains the...
Questions
question
Mathematics, 09.07.2019 01:30