answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
jok3333
22 days ago
15

7. Test Average and Grade Write a program that asks the user to enter five test scores. The program should display a letter grad

e for each score and the average test score. Write the following methods in the program: calcAverage: This method should accept five test scores as arguments and return the average of the scores. determineGrade: This method should accept a test score as an argument and return a letter grade for the score, based on the following grading scale: Score Letter Grade 90-100 A 80-89 B 70-79 C 60-69 D Below 60 F
Computers and Technology
1 answer:
Amiraneli [1K]22 days ago
5 0

Answer:

The solution code is written in Java.

  1. import java.util.Scanner;
  2. public class TestScore {
  3.    public static void main(String[] args) {
  4.        Scanner input = new Scanner(System.in);
  5.        System.out.print("Please enter first score: ");
  6.        double firstScore = input.nextDouble();
  7.        System.out.println("Grade: " + determineGrade(firstScore));
  8.        System.out.print("Please enter second score: ");
  9.        double secondScore = input.nextDouble();
  10.        System.out.println("Grade: " + determineGrade(secondScore));
  11.        System.out.print("Please enter third score: ");
  12.        double thirdScore = input.nextDouble();
  13.        System.out.println("Grade: " + determineGrade(thirdScore));
  14.        System.out.print("Please enter fourth score: ");
  15.        double fourthScore = input.nextDouble();
  16.        System.out.println("Grade: " + determineGrade(fourthScore));
  17.        System.out.print("Please enter fifth score: ");
  18.        double fifthScore = input.nextDouble();
  19.        System.out.println("Grade: " + determineGrade(fifthScore));
  20.        System.out.println("Average score: " + calcAverage(firstScore, secondScore, thirdScore, fourthScore, fifthScore));
  21.    }
  22.    public static double calcAverage(double score1, double score2, double score3, double score4, double score5){
  23.        double average = (score1 + score2 + score3 + score4 + score5) / 5;
  24.        return average;
  25.    }
  26.    public static String determineGrade(double score){
  27.        if(score >= 90){
  28.            return "A";
  29.        }
  30.        else if(score >= 80 ){
  31.            return "B";
  32.        }
  33.        else if(score >=70){
  34.            return "C";
  35.        }
  36.        else if(score >=60){
  37.            return "D";
  38.        }
  39.        else{
  40.            return "F";
  41.        }
  42.    }
  43. }

Explanation:

First, implement the method, calcAverage(), to handle five test scores. Calculate the average within this method and return it.

Then, create a separate method, determineGrade(), which accepts a single score and returns the corresponding grade based on defined ranges.

After establishing the two methods, you can prompt the user for five test scores via the Java Scanner class. Initialize a Scanner object to receive user input (Line 7). Subsequently, use the getDouble() method for entering the scores which are assigned to variables firstScore, secondScore, thirdScore, fourthScore, and fifthScore, accordingly. Each time a score is provided, invoke determineGrade() using that score and print out the resulting grade.

Finally, call calcAverage() with the first score variables as inputs and output the average result.

You might be interested in
Debug the program so it prints the factorial of a positive integer entered by the user. This is calculated by multiplying all th
Natasha_Volkova [1026]
The primary issue was declaring int prod within the while loop, which caused prod to reset to 1 each time the loop executed.
3 0
1 month ago
A network administrator notices that some newly installed Ethernet cabling is carrying corrupt and distorted data signals. The n
zubka84 [1067]

Answer:

EMI and RFI

Explanation:

EMI, or Electromagnetic Interference, can also be referred to as Radio-frequency Interference (RFI) within the radio frequency domain.

An unshielded ethernet cable, made from copper, might function as an antenna; any external noise that interferes with it can corrupt the data signal, resulting in data integrity issues and distorted signals.

6 0
19 days ago
In cell e5, create a formula using the vlookup function to determine the dog type for teen anna morante based on the program cod
Natasha_Volkova [1026]
Hi! For utilizing the VLOOKUP function, you require the value to search for, the table’s range, and the specific column that has the return value. In your scenario, you provided both the range and the column; however, it’s unclear what value you wish to look up. For this explanation, let’s assume you want to search for the value in cell D5. Feel free to modify it according to your needs.

In syntax form, it will be:
=VLOOKUP(D5,G4:H7,2)
3 0
28 days ago
Read 2 more answers
One example of how psychological research can be used to control harmful behavior would be __________. A. fooling individuals th
Harlamova29_29 [1022]

Psychological research can be misused for harmful reasons like deceiving people through emotions, using propaganda to shift beliefs, or media manipulation.

However, it can also be beneficial, which is the intent of the question. Clearly, from the options presented, only (D) enhancing communication and relationships represents a positive application of psychological research.

8 0
1 month ago
Read 2 more answers
Brendan is examining a report using the Design view. Which section in the Design view is going to appear only once on the first
maria [1035]

The Report Header Section is the part in Design view that appears only on the first page and may include logos and title details.

Clarification:

In Design view, the Create tab allows for report creation with just a click. The Report Wizard can also assist in generating reports with various options.

After initiating a report, you will realize that it contains multiple sections, requiring decisions on the data to be included in each section.

The Report Header Section shows at the top of the first page and only once during the report generation. It features elements like the logo, report title, and current date.

3 0
1 month ago
Other questions:
  • Susan is assisting a web designer to create a promotional web page on eco-friendly classroom designs. She uses color combination
    5·1 answer
  • Light travels at 3 × 108 meters per second. A light-year is the distance a light beam travels in one year.Write a PYTHON program
    14·1 answer
  • Write a for loop to print all NUM_VALS elements of array hourlyTemp. Separate elements with a comma and space. Ex: If hourlyTemp
    6·1 answer
  • Write a statement that reads a floating point value from standard input into temperature. Assume that temperature. has already b
    6·1 answer
  • RADIAC instruments that operate on the ionization principle are broken down into three main categories based on what?
    15·1 answer
  • What type of memory can support quad, triple, and dual channels?
    5·1 answer
  • A wireless network does not benefit like a wired network does, when it comes to collision reduction. Which device reduces collis
    6·1 answer
  • Using the format method, fill in the gaps in the convert_distance function so that it returns the phrase "X miles equals Y km",
    12·1 answer
  • In a ____ queue, customers or jobs with higher priorities are pushed to the front of the queue.
    14·1 answer
  • Write a program whose input is a string which contains a character and a phrase, and whose output indicates the number of times
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!