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]
3 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]3 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
A(n) ___________________________ is a pl/sql block that executes in place of a dml action on a database view.
Zinaida [17]

A(n)<u> Instead Of trigger </u>is a pl/sql block that manages in place of a dml action on a database view.

<h3>Why instead of triggers are used?</h3>

INSTEAD OF triggers describe how to perform insert, update, and delete functions against complex views. INSTEAD OF triggers permit applications to use a view as the sole interface for all SQL operations.

<h3>What are the after triggers?</h3>

An after trigger runs after the connected insert, update, or delete changes are involved to the table. The WHEN condition can be used in an SQL trigger to specify a state. If the condition evaluates to true, the SQL views in the SQL trigger routine body are run.

To learn more about Instead Of trigger, refer

brainly.com/question/21564232

#SPJ4

6 0
2 years ago
In Python write a program that reads a list of integers into a list as long as the integers are greater than zero, then outputs
Lilit [14]

Answer:

ansList =input().split() #get input and split it by space

ansList = [int(i) for i in ansList if int(i)>0] #turn string to integer,and get all positive integers

print(ansList)

Explanation: I think this would work for you. I leace comments in the answer.

3 0
2 years ago
After the closing entries have been posted:
Nimfa-mama [501]
Closing entries are entries<span> made at the end of an accounting period to zero out all temporary accounts. The balances are transferred to permanent accounts. 
After the closing entries have been posted:
A. the temporary accounts are zeroed out
Revenues and expenses are transferred to the income Summary Account and then Income Summary is closed to Retained earnings.</span>
7 0
3 years ago
What is one distinguishing feature of Italian opera buffa in comparison to comic opera of other countries?
vodka [1.7K]

Answer:

It is sung throughout.

Explanation:

5 0
3 years ago
Jennifer frequently uses a few programs on her laptop. Where will she find all the frequently used program icons in her computer
borishaifa [10]

Answer:

Jennifer can find the list of all the frequently used program icons on the left pane of the start menu. Below this list, still on the left pane, all programs installed on her computer will be listed in alphabetical order.

Explanation:

I hope this helps

7 0
4 years ago
Other questions:
  • Datta Computer Systems is considering a project that has the following cash flow data. What is the project's IRR? Note that a pr
    10·1 answer
  • Which of the following is a type of monitor port?
    10·1 answer
  • The frame work for storing records in database is a
    7·1 answer
  • What is a packet?
    10·1 answer
  • Last semester, Henri bought his textbooks over the Internet and saved a considerable amount of money. Classes start in a few day
    12·2 answers
  • Which of the following modes of replication requires a very low latency network connection and ensures data remains in synch wit
    13·1 answer
  • In the following code, use a lock to protect any data that might need protecting. Keep your critical sections as small as possib
    8·1 answer
  • In a dark place you have only a match , a twig , campfire logs , and oil lamp and a candle which do you literally first /
    15·1 answer
  • How many are required for an accurate signal?
    13·1 answer
  • How many 64 x 8 memory chips are needed to provide 4096 x 16 memory capacity? Create 4096 x 16 memory with the required number o
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!