Write a program that calculates the average of a group of test scores, where the lowest
score in the group is dropped. It should use the following functions:
• void getScore() should ask the user for a test score, store it in a reference parameter
variable, and validate it. This function should be called by main once for each
of the five scores to be entered.
• void calcAverage() should calculate and display the average of the four highest
scores. This function should be called just once by main and should be passed the
five scores.
• int findLowest() should find and return the lowest of the five scores passed to it.
It should be called by calcAverage, which uses the function to determine which of
the five scores to drop.
Input Validation: Do not accept test scores lower than 0 or higher than 100.
#include <iostream>
#include <iomanip>
using namespace std;
//Function prototype
int GetScore(int, int, int &Total);
double CalcAverage(int, int);
int FindLowest(int ScoreArray[5]);
// Main function
int main()
{
int ScoreArray[5];
int TestScore = 0;
double Average = 0;
int Lowest = 0;
int Total = 0;
for (int i = 1; i <= 5; i++)
{
TestScore = GetScore(TestScore,i,Total);
ScoreArray[i-1];
}
Lowest = FindLowest(ScoreArray);
Average = CalcAverage(Lowest, Total);
cout << "Lowest Score: " << Lowest << endl;
cout << "the average is: " << Average << endl;
return 0;
}
// Function 1
int GetScore(int TestScore, int i, int &Total)
{
cout << " enter score for exam << i << " ";
cin >> TestScore;
// Function 2
double CalcAverage(int Lowest, int Total);
{
int Sum = 0;
double Average = 0;
Sum = Total - Lowest;
Average = Sum / 4;
return Average;
}
// Function 3
int FindLowest(ScoreArray[5])
{
int Smallest = ScoreArray[0];
for (int i = 1; i < 5; i++
{
if (ScoreArray[i] < Smallest)
Smallest = ScoreArray[i];
}
return Smallest;
}
I dont know whats the problem with it, any suggestions?
It's clear from the given code that you understand C++ syntax. Fix all of the missing ')'s and ';'s to start with. Then post the updated code, sample input, and output from the given sample input.
What is the error you are getting? From what I see, you are missing many parentheses and semicolons. Also, if this is a lab or homework assignment, I doubt your professor will by happy with the input validation