Oct 27, 2018 at 4:22pm UTC
I am writing a program that will find the average of 5 judges score subtracting the highest and lowest score. I am not allowed to use arrays on this assignment.
Everything seems functional except I keep getting C4700 compiler errors on lines 11-15. Any insight or help would be greatly appreciated.
[code]
Put the code you need help with here.
#include <iostream>
#include <iomanip>
using namespace std;
void getScore(double );
void calcAverage(double, double, double, double, double);
int findLowest(double, double, double, double, double);
int findHighest(double, double, double, double, double);
int main() {
double j1, j2 , j3 , j4 , j5 ;
getScore(j1);
getScore(j2);
getScore(j3);
getScore(j4);
getScore(j5);
calcAverage(j1, j2, j3, j4, j5);
}
void getScore(double)
{
cout << "Enter a judge score\n";
double score;
cin >> score;
while (score < 0 || score > 11)
{
cout << "Please enter a valid judge score that is between 0 to 10\n";
cin >> score;
}
}
void calcAverage(double s1, double s2, double s3, double s4, double s5)
{
double sum;
double lowest, highest;
double average;
highest = findHighest(s1, s2, s3, s4, s5);
lowest = findLowest(s1, s2, s3, s4, s5);
sum = s1 + s2 + s3 + s4 + s5 - (lowest + highest);
average = sum / 3.0;
cout << setw(4) << fixed << showpoint << setprecision(2);
cout << "Your score is: " << average << endl;
}
int findLowest(double s1, double s2, double s3, double s4, double s5)
{
double lowest = s1;
if (s2 < lowest)
{
lowest = s2;
}
if (s3 < lowest)
{
lowest = s3;
}
if (s4 < lowest)
{
lowest = s4;
}
if (s5 < lowest)
{
lowest = s5;
}
cout << "The lowest test score is: " << lowest << endl;
return lowest;
}
int findHighest(double s1, double s2, double s3, double s4, double s5)
{
double highest = s1;
if (s2 < highest)
{
highest = s2;
}
if (s3 < highest)
{
highest = s3;
}
if (s4 < highest)
{
highest = s4;
}
if (s5 < highest)
{
highest = s5;
}
cout << "The highest test score is: " << highest << endl;
return highest;
}