1answer.
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
bixtya [17]
2 years 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:
Alenkasestr [34]2 years ago
5 0

Answer:

The code solution 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:

Firstly, create the method, <em>calcAverage()</em>, that takes five test scores. Within the method, calculate the average and return it as output. (Line 33 - 36)

Next, create another method, <em>determineGrade()</em>, which takes only one score and return the grade based on the range of the  score. (Line 38 -54)

Once the two required methods are created, we are ready to prompt use for input five test scores using Java Scanner class. To use get user input, create a Scanner object (Line 7). Next, use getDouble() method to get an input score and assign it to variables firstScore, secondScore, thirdScore, fourthScore & fifthScore, respectively. Once a score input by user, call determineGrade() method by passing the input score as argument and immediately print out the return grade. (Line  9 - 27)

At last, call calcAverage() method by passing the first test score variables as argument and print out the returned average value. (Line 29).

You might be interested in
how can i stop this stupid thing from sending me emails because my school decides to not give you a block option
tekilochka [14]

Answer:

If it on g mail you go to the spam box and then press the spammers to account and then press block and then you will block them.

5 0
2 years ago
Read 2 more answers
In general, the right amount of time to do freewriting is
zlopas [31]
THE correct answer is c 10 minuets
4 0
3 years ago
Read 2 more answers
What is the least effective way to create balance and flow in your life?
ratelena [41]
<span>Act on your emotions in the moment instead of thinking about them. </span>
6 0
3 years ago
The Margin controls adjust what part of the worksheet?
ivann1987 [24]

Answer:

B

Explanation:

6 0
3 years ago
Read 2 more answers
To nest one structure within another structure, you a. define both structures and then create a data member of the nested struct
Lubov Fominskaja [6]

Answer:

Hence the correct option is option a) define both structures and then create a data member of the nested structure type within the other structure.

Explanation:

To make Address nested to Employee, we've to define Address structure before and out of doors Employee structure and make an object of Address structure inside Employee structure.

For example, we may need to store the address of an entity employee in a structure.

5 0
3 years ago
Other questions:
  • True or False: You cannot change the default margin size for Word documents.  
    6·1 answer
  • What command in windows re gives you the opportunity to manage partitions and volumes installed on the system?
    7·1 answer
  • How does adding additional light bulbs affect a series circuit?
    10·1 answer
  • To have the most impact when using email, you should structure your messages so that
    5·1 answer
  • list the version of Windows you are using XP, Windows7, Windows8 and then explain the steps you will use to find the programs
    6·1 answer
  • What does the minimum password age setting control?
    15·1 answer
  • Hey yall wanna send me some just ask for my phone #
    13·1 answer
  • Which of the following is not true?A. An organization may express its cybersecurity state through a Current Profile to report re
    10·1 answer
  • (Please answer both parts, please)
    8·2 answers
  • Pleaseeeee helpppppppp​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!