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
Which of the following is an advantage of using variables?
GaryK [48]

Answer:

D. It makes it less likely that an error will be introduced into the code.

Explanation:

7 0
3 years ago
Which of the following statements should be avoided when developing a mission statement?
Citrus2011 [14]

Answer: The how-to statements

Explanation:

The mission statement is simply a short summary of the purpose of a company. It is the guideline on how a company will operate. The mission statement states the reason for the existence of a company, products sold or service rendered and the company's goals.

The mission statement should be brief but comprehensive, consist of simple words and describe the “who, what, and where” of the organization.

Therefore, the incorrect option based on the explanation above is "The how-to statements". This shouldn't be part of the mission statement.

3 0
3 years ago
Given an array declared to hold 100 values, the smallest index that can be used with the array is
Aneli [31]
In C influenced languages - 0.
8 0
3 years ago
Assume in the for loop header, the range function has the three arguments: range (1, 10, 3), if you were to print out the value
Licemer1 [7]

Answer:

1, 4, 7

Explanation:

The instruction in the question can be represented as:

for i in range(1,10,3):

   print i

What the above code does is that:

It starts printing the value of i from 1

Increment by 3

Then stop printing at 9 (i.e.. 10 - 1)

So: The sequence is as follows

Print 1

Add 3, to give 4

Print 4

Add 3, to give 7

Print 7

Add 3, to give 10 (10 > 10 - 1).

So, it stops execution.

6 0
2 years ago
Which page layout is most commonly used for a website with a large navigation menu?
mestny [16]

Explanation:

The Name is called, (navigation menu..)

to direct users 2 info., they look up...

7 0
2 years ago
Other questions:
  • White arrows in the middle of the lane indicate whether the lane must __________.
    8·2 answers
  • What is another name for a central processing unit? Computer Integrated circuit Microprocessor Transistor
    9·2 answers
  • Which of the following is considered part of the process in the systems thinking example of a TPS?
    6·1 answer
  • A(n) _____ measures the ability to juggle a variety of demands, as in a manager's job where the candidate is presented with simu
    8·1 answer
  • Give an O(log m + log n)-time algorithm that takes two sorted lists of sizes m and n, respectively, as input and returns the ith
    7·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    5·1 answer
  • Mention five features on the desktop screen​
    5·1 answer
  • How to use access?<br> like working in access and bringing tables and stuff
    5·1 answer
  • Give an idea of a law u would like to create
    5·2 answers
  • Difference between switch and switch lite
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!