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
3 months 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]3 months 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
You just read an msds for acetic acid. based on what you read, what type of information is included in an msds sheet? record you
maria [1035]
The MSDS sheet is packed with details such as the owning company of the acid, the ingredient's makeup, potential hazards and their management, first aid steps, and firefighting precautions, among other things. It provides comprehensive information necessary for laboratory safety when handling various chemicals. 
3 0
2 months ago
If a packet gets “sucked down a black hole” (figuratively speaking) and is not received by its sender, and no message is sent ba
Harlamova29_29 [1022]

If a packet gets figuratively “sucked into a black hole” and is not received by the original sender, with no message returned to clarify the situation, there is an issue. This lack of communication indicates there is a problem with the _____.

A.) ICMP

B.) TCP/IP

C.) HTTP

D.) ISO

A.) ICMP

I hope this information is useful and wish you the best.

~May

0 0
3 months ago
The email application used by Jim’s office is sending emails with viruses attached to them to user’s computers. What step should
Harlamova29_29 [1022]
Jim should first try D. to check for and install patches or software updates.
7 0
2 months ago
Other questions:
  • A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun. To ac
    11·2 answers
  • To finish creating a design for the webpage, use one shape to cut away part of the other. Create a 700 pixel by 700 pixel square
    10·1 answer
  • Q2 - Square Everything (0.25 points) Write a function called square_all that takes an input called collection that you assume to
    7·1 answer
  • Henry, a graphic artist, wants to create posters. Which software should Henry use for this purpose?
    13·1 answer
  • Describe a situation involving making a copy of a computer program or an entertainment file of some sort for which you think it
    7·1 answer
  • Leah Jones is the IT manager at Rock Solid Outfitters, a medium-sized supplier of outdoor climbing and camping gear. Steve Allen
    13·1 answer
  • Write a function in the cell below that iterates through the words in file_contents, removes punctuation, and counts the frequen
    6·1 answer
  • Huan wants to enter the science fair at his school. He has a list of ideas for his project. Which questions could be answered th
    14·1 answer
  • Why would Network Systems employees be employed by the government?
    12·2 answers
  • ____ was developed to enable web authors to implement interactive content on web sites, such as to animate an item, or pop up a
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!