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 02:00
Aletter or menu command that starts an action when the user presses the designated letter and the alt key together is called what?
Answers: 1
question
Computers and Technology, 22.06.2019 10:30
Dave has to create animations for a game. which tool can dave use?
Answers: 3
question
Computers and Technology, 22.06.2019 13:00
Which option should u select to ignore all tracked changes in a document
Answers: 1
question
Computers and Technology, 23.06.2019 17:00
The more powerful, 60 volt cables and the main power shut-off on an hev are both colored orange.
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, 31.01.2020 16:51
Questions on the website: 13722367