Please i want help Write a C++ program that will ask the user to enter 4 quiz sc
ID: 3667185 • Letter: P
Question
Please i want help
Write a C++ program that will ask the user to enter 4 quiz scores. These scores should be from 0 to 100. Use a procedure and pass by reference to get these scores. Write a function that will find the lowest score. This score will be sent back thru the function call. You still need to pass the scores by value to this function. Write a function that will calculate the average score. This value will be sent back to main through the call. Pass the scores and low by value. Now write a procedure that will display the scores, lowest score and average. This is a procedure and will return nothing to main.
Screen Drawing is below.
Enter quiz 1: x
Enter quiz 2: x
Enter quiz 3: x
Enter quiz 4: x
Quiz 1: x
Quiz 2: x
Quiz 3: x
Quiz 4: x
Low Score: x
Average Score: x.x
Project Notes:
Program main will have the following variables:
main will have 4 procedures or functions
Explanation / Answer
#include <iostream>
#include <iomanip>
using namespace std;
int getScore();
void calcAverage(int, int, int, int, int);
int findLowest(int, int, int, int, int);
int main()
{
cout << "Enter 5 test scores. The lowest of the five will be dropped. ";
int sc1 = getScore(), sc2 = getScore(), sc3 = getScore(), sc4 = getScore(), sc5 = getScore();
calcAverage(sc1, sc2, sc3, sc4, sc5);
return 0;
}
int getScore()
{
int score;
cout << "Enter Score between 0-100: ";
cin >> score;
while ( score < 0 || score > 100 )
{
cout << "Score must be between 0 and 100: ";
cin >> score;
}
return score;
}
void calcAverage(int sc1, int sc2, int sc3, int sc4, int sc5)
{
double avg;
cout << "I will now find the average of the 4 top scores entered. ";
avg = ( sc1 + sc2 + sc3 + sc4 + sc5 - findLowest(sc1, sc2, sc3, sc4, sc5) ) / 4.0;
cout << showpoint << fixed << setprecision(2) << avg << endl;
}
int findLowest(int sc1, int sc2, int sc3, int sc4, int sc5)
{
int lowScore = sc1;
if ( sc2 < lowScore )
lowScore = sc2;
if ( sc3 < lowScore )
lowScore = sc3;
if ( sc4 < lowScore )
lowScore = sc4;
if ( sc5 < lowScore )
lowScore = sc5;
return lowScore;
}