This is whats required and I don't know arrays yet so that's kinda out. While loop does not execute with if ststement after cins and its all a little confusing right now could somebody share some light?
Requirements:
1. Input the contestant’s first name followed by the 5 judges’ scores. You do not know how many contestants there are. Design the loop so the loop terminates when you are finished entering contestants.
2. Input validation: Do not accept a judge’s score that is less than 1 or greater than 10. As each score is entered send the score to a function to test the score’s validity.
3. Use function calcAvgScore that has the contestant’s 5 scores as input parameters
a. returns the average score for that contestant.
b. Calls two functions, findLowest and findHighest which both accept the 5 scores as input parameters and return the lowest and highest scores, respectively.
4. Do not use global variables. All variables used in the functions must be passed as parameters or declared locally.
5. At the end of the program, display the winner and winning score (rounded to 2 decimal places).
And this is what I have come up with so far about 4 hrs lol.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
int quit;
int i;
string name;
double score = 0.0;
double total = 0.0;
while (quit != 2)
{
cout << "Enter first name:" << endl;
cin >> name;
for (i = 0; i < total; i++)
{
cout << "Enter judge1 score: " << endl;
cin >> score;
if (score < 1 || score > 10)
{
cout << "Try again" << endl;
cin >> score;
}
cout << "Enter judge2 score: " << endl;
cin >> score;if (score < 1 || score > 10)
{
cout << "Try again" << endl;
cin >> score;
}
cout << "Enter judge3 score: " << endl;
cin >> score;
if (score < 1 || score > 10)
{
cout << "Try again" << endl;
cin >> score;
}
cout << "Enter judge4 score: " << endl;
cin >> score;
if (score < 1 || score > 10)
{
cout << "Try again" << endl;
cin >> score;
}
cout << "Enter judge5 score: " << endl;
cin >> score;
if (score < 1 || score > 10)
{
cout << "Try again" << endl;
cin >> score;
}
total += score;
}
cout << "1 to continue or 2 to stop: " << endl;
cin >> quit;
}
total += score;
cout << "Total:" << total << endl;
return 0;
}
|