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
What is the binary number for the decimal 1024? ​
GaryK [48]

Answer:

10000000000

Explanation:

While a typical byte only goes up to 8 digits, you can expand past that by having each integer past the initial 8 just double the amount from before

8 0
3 years ago
Read 2 more answers
Compare and contrast the properties of a centralized and a distributed routing algorithm. give an example of a routing protocol
Naily [24]

Answer and Explanation:

Centralized : Central node in the system gets whole data about the system topology, about the traffic and about different hubs. This at that point transmits this data to the particular switches. The benefit of this is just a single hub is required to keep the data. The hindrance is that if the focal hub goes down the whole system is down, for example single purpose of disappointment.

Distributed: Distributed nodes gets data from its neighboring hubs and afterward takes the choice about what direction to send the parcel. The weakness is that if in the middle of the interim it gets data and sends the parcel something changes then the bundle might be deferred.

Example :

Link State takes Centralized approach

Distance Vector takes Decentralize approach

8 0
3 years ago
1. The________  member function moves the read position of a file.
emmasim [6.3K]

Answer:

Answers explained with appropriate comments

Explanation:

1. seekp()   //the seekp sets the position where the next character is to be   //inserted into the output stream.

2. fstream  //fstream is used for input and output for files

//just like iostream for input and output data

3. tellp();  //tellp returns the "put" or write position of the file.

4. ios::ate  //ate meaning at the end, sets the file output at the file end

5. binary files  //binary files only store 0s and 1s

6. seekg()  //seekg is used to move write position of the file

7. put  //this is used to "put" or set records or arrays to a single file

8. std::ws , skips //the std::ws is used to discard leading whitespace from an //input stream

9. peek //this looks at the next character in the input sequence

10. get, peak //get and peek do not skip leading whitespace characters

8 0
3 years ago
You have double-clicked a device in Device Manager to open its Properties window. Where can you find information about IRQs the
Setler [38]

To find information about IRQs the device might use, make alteration to the View menu option and then change it to Resources by type.

<h3>How do one find information about IRQs?</h3>

The best way to see IRQ information in Windows is through the use of Device Manager.

Note that for one to be able to find information about IRQs the device might use, one has to makes some changes to the View menu option and then one can change it to Resources by type to be able to see the Interrupt request (IRQ) part.

Learn more about Device Manager from

brainly.com/question/869693

#SJ1

7 0
2 years ago
By default, the pfsense firewall allows unrestricted outbound access from the lan interface. true or false?
Sav [38]

The statement "By default, the pfSense firewall allows unrestricted outbound access from the lan interface" is true.

pfSense is free and open source firewall and router that can be installed on a physical computer or a virtual machine. Teh goal is to make the machine a dedicated firewall/router for a network.

 It features unified threat management, load balancing, multi WAN etc.


8 0
4 years ago
Read 2 more answers
Other questions:
  • Q3** Write a query to create a new price list for books written by the same author. Allow the user to enter only the first 4 let
    15·1 answer
  • What is a organisation in office technology
    7·1 answer
  • INTRODUCTION TO JAVA​
    8·1 answer
  • The autofilter sort method works on a(n)____ field(s).
    15·1 answer
  • Sql is an example of a ________ category programming language. 4gl 3gl 5gl 2gl
    15·1 answer
  • What are the careers needed to create a video game? Name all the careers involved please.
    15·1 answer
  • In this problem you will test and analyze the following sorting algorithms: Selection, Bubble, Insertion, Merge, and Quick. You
    14·1 answer
  • Write a while loop that prints
    13·1 answer
  • Any song recommendations, pls dont say 6ix9ine or lil pump
    5·2 answers
  • Please help.........​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!