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
jekas [21]
3 years ago
11

Write a program that asks the user to enter 5 test scores. The program will display a letter grade for each test score and an av

erage grade for the test scores entered. Three functions are needed for this program.
Computers and Technology
1 answer:
lana66690 [7]3 years ago
5 0

Answer:

The program in C++ is as follows:

#include <iostream>

using namespace std;

double average(double s1, double s2, double s3, double s4, double s5){

   double avg = (s1 + s2 + s3 + s4 + s5)/5;

   return avg;}

char lGrade(double score){

   char grade;

   if(score>= 90 && score <= 100){ grade ='A'; }

   else if(score>= 80 && score <= 89){ grade ='B'; }

   else if(score>= 70 && score <= 79){ grade ='C'; }

   else if(score>= 60 && score <= 69){ grade ='D'; }

   else if(score < 60){ grade ='F'; }

   return grade;}

int main(){

   double s1,s2,s3,s4,s5;

   cin>>s1>>s2>>s3>>s4>>s5;

   double avg = average(s1,s2,s3,s4,s5);

   cout<<s1<<" "<<lGrade(s1)<<endl;

   cout<<s2<<" "<<lGrade(s2)<<endl;

   cout<<s3<<" "<<lGrade(s3)<<endl;

   cout<<s4<<" "<<lGrade(s4)<<endl;

   cout<<s5<<" "<<lGrade(s5)<<endl;

   cout<<avg<<" "<<lGrade(avg)<<endl;

   return 0;}

Explanation:

The three functions to include in the program are not stated; so, I used the following functions in the program

1. The main function

2. average function

3. Letter grade function

The average function begins here

double average(double s1, double s2, double s3, double s4, double s5){

This calculates the average

   double avg = (s1 + s2 + s3 + s4 + s5)/5;

This returns the calculated average

   return avg;}

The letter grade function begins here

char lGrade(double score){

This declares the grade

   char grade;

If score is between 90 and 100 (inclusive), grade is A

<em>    if(score>= 90 && score <= 100){ grade ='A'; }</em>

If score is between 00 and 89 (inclusive), grade is B

<em>    else if(score>= 80 && score <= 89){ grade ='B'; }</em>

If score is between 70 and 79 (inclusive), grade is C

<em>    else if(score>= 70 && score <= 79){ grade ='C'; }</em>

If score is between 60 and 69 (inclusive), grade is D

<em>    else if(score>= 60 && score <= 69){ grade ='D'; }</em>

If score is less than 60, grade is F

<em>    else if(score < 60){ grade ='F'; }</em>

This returns the calculated grade

   return grade;}

The main begins here

int main(){

This declares the 5 scores

   double s1,s2,s3,s4,s5;

This gets input for the 5 scores

   cin>>s1>>s2>>s3>>s4>>s5;

This calls the average function for average

   double avg = average(s1,s2,s3,s4,s5);

This calls the letter grade function for the 5 scores

<em>    cout<<s1<<" "<<lGrade(s1)<<endl;</em>

<em>    cout<<s2<<" "<<lGrade(s2)<<endl;</em>

<em>    cout<<s3<<" "<<lGrade(s3)<<endl;</em>

<em>    cout<<s4<<" "<<lGrade(s4)<<endl;</em>

<em>    cout<<s5<<" "<<lGrade(s5)<<endl;</em>

This calls the average function for the average

   cout<<avg<<" "<<lGrade(avg)<<endl;

You might be interested in
Cheri needs to write a small program that interacts with the user. What step will allow her to do this?
Alinara [238K]

Answer:

Including a input statement

Explanation:

You need a input statement in order for it to work, here´s an example;

script.parent.click <u>then</u>

you need the ¨.mouse¨ after parent or it wouldnt work.

8 0
3 years ago
Read 2 more answers
An office uses an application to assign work to its staff members. The application uses a binary sequence to represent each of 1
fenix001 [56]

Answer: I believe the answer is: A, 5.

Explanation:

6 0
3 years ago
When you sort a cell range using a to z or z to a, what is rearranged?
kvv77 [185]
Only those cells names. Most common mistake in excel. If you want to sort rows make sure you highlight everything and then use sort function on column
5 0
3 years ago
Im lonellly whos down to date me
inna [77]

Answer:

I was actually just looking to help with someone's schoolwork. . .

Explanation:

5 0
3 years ago
Read 2 more answers
Which website can help you find antivirus software ?
sergey [27]

If you have windows you have Windows Defender Installed already!!

5 0
3 years ago
Other questions:
  • The syntax used for referencing cells with their worksheet names is the sheet name, followed by ____, then the usual column lett
    8·1 answer
  • Which of the following is an unintended consequence of pesticide use on crops?
    10·1 answer
  • Assuming a computer has a single processor and a single core with no support for parallel execution, explain why running a multi
    11·1 answer
  • Employees don't have to comply with PPE requirements if they feel the PPE isn't necessary for the particular task they performed
    14·2 answers
  • How do you copy and paste a screenshot on an hd computer
    12·2 answers
  • Toby has lost valuable data on his computer a number of times due to system crashes caused by viruses. He decides to invest in a
    13·1 answer
  • The stream cipher described in Definition 2.1.1 can easily be generalized to work in alphabets other than the binary one. For ma
    10·1 answer
  • What soft ware can you use to erase all of your data from a hard drive safely
    13·1 answer
  • Help me plzzzz ASAP T-T and it's Cyber Security but my last day of school is tomorrow and I'll graduate in June 24 so plzzzzz I
    12·1 answer
  • Priortization is an example of a skill that helps you reach long term goals because
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!