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
Select the correct answer.
Mekhanik [1.2K]
The best answer is A
5 0
2 years ago
Read 2 more answers
A __________ note is a private note that you leave for yourself or for other people who might use the presentation file
BaLLatris [955]

Answer:

The answer is that it is a speaker note.

Explanation:

It leaves a note for people that use presentation files. I use it all the time on my google slides.

7 0
2 years ago
In reference to computer communications, what does the term noise mean?
jeka94
Noise usually means static.
6 0
2 years ago
Read 2 more answers
Guys I need help I cant download anything in the app store I restarted my phone and I know it's not the space on my phone I have
Simora [160]

Can you give me further explanation? For example, how is your phone not letting you download things? What model of a phone is it? what update is it on? and to what extent can you download something?

4 0
2 years ago
Which program will have the output shown below?
Nutka1998 [239]

Answer: Python

Explanation: All I know is that the programming language is Python.

8 0
2 years ago
Read 2 more answers
Other questions:
  • Which topology enables only one person, at one time, to send data to others on the network?
    6·1 answer
  • Your browsing the Internet and realize your browser is not responding which of the following will allow you to immediately exit
    14·2 answers
  • In the writing process, after you ve narrowed down your topic, you can use the _______ technique to view a topic from different
    9·2 answers
  • Where does the CPU store its computations?
    14·1 answer
  • The user cannot use a computer system without.................... software<br><br>​
    13·2 answers
  • Please could you help me
    6·2 answers
  • This site isn't letting me add my ans and wut should I do?
    15·1 answer
  • Write a program to output 3 lines of text with the following information:
    7·1 answer
  • For angular how can we set up th edatabse.
    11·1 answer
  • Viruses that load from usb drives left connected to computers when computers are turned on are known as.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!