Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assume that two-dimensional arrays are used to store information about students' grades. The first is called studentScores and contains the students' numerical scores as integers.

Assume that two-dimensional arrays are used to store information about students' grades. The first is called studentScores and contains the students' numerical scores as integers. The other is studentLetters and contains the corresponding letter grades as a String (i.e. "A", "B", "C", "D", or "F"). Each row represents an individual student and each column a different assessment.

For example, if studentScores[0][0] contains 92, then the contents of studentLetters[0][0] will contain the corresponding letter grade. In this case, the letter grade is A because the professor has used a standard grading scale. Note that the professor might choose a different grading scale. Do not assume scores of 90 or above are the letter grade A.

public class Gradebook
{

      private int[][] studentScores;
      private String[][] studentLetters;

      // constructors not shown

      // postcondition: returns −1.0 if letterGrade does not appear in studentLetters
      // otherwise, returns the average of all studentScores with corresponding
      // studentLetters values that are equal to the parameter letterGrade
      public double letterAverage(String letterGrade)
      {

      }

      // other methods not shown

}

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. The method letterAverage returns −1.0 if none of the student scores corresponds to the given letter grade.

For example, given the following two-dimensional arrays:

studentScores:      96 72 84 65 89 60
                    78 86 75 61 85 73

studentLetters:     A C B D A D
                    B B C D B C

The method call letterAverage("B") would return the number 83.25, which is the average of the four scores that correspond to the letter grade B.

The method call letterAverage("F") would return −1.0 because none of the studentLetters elements are equal to F.

Complete the method letterAverage below. Be sure to include the method header.

Step by Step Solution

3.47 Rating (160 Votes )

There are 3 Steps involved in it

Step: 1

Gradebookjava Public class book Private int studentScores Private string s... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems A Practical Approach to Design Implementation and Management

Authors: Thomas Connolly, Carolyn Begg

6th Edition Global

132943263, 978-0132943260

More Books

Students also viewed these Programming questions

Question

Describe how cookies can be used to store information about a user

Answered: 1 week ago

Question

why you want to attend graduate school in general;

Answered: 1 week ago

Question

$250 is what percent less than $750?

Answered: 1 week ago

Question

How much is $102 after a decrease of 2%?

Answered: 1 week ago

Question

How much is $150 after an increase of 150%?

Answered: 1 week ago