Lost In Program Out Of Options

Looking to see if anyone has some advice for me.... I'm creating a program for class that is supposed to output the the winner of a talent show based on 5 judges scores. Everything runs fine however i am unable to figure out how to store and output the winners name along with their high score. I am not allowed to use arrays at the moment ... Any Ideas? This Is The Major Part To My Program
Apologies in advance I tried to make easier for you to read but couldn't figure out an easy way in this text box.

#include <iostream>
#include <string>
using namespace std;

// Creating Functions For Call Within Int Main()
double calcavg_Score(double, double, double, double, double);
double find_Lowest(double, double, double, double, double);
double find_Highest(double, double, double, double, double);

int main()
{
// Defining Variables For User Input
int P1;
int P2;
int P3; // -------------- P = Points Thus Is = Score
int P4;
int P5;
string name;

// Defining Variables For The Usages Of Functions
double score1 = 0;
double score2 = 0;
double score3 = 0;
double score4 = 0;
double score5 = 0;

// Beginning Source Code For User Input
cout << "Enter The Name of The Contestant, If There Are No More Contestants Enter Done" << endl;
cin >> name;
cout << " " << endl;
do
{
for (int judge = 1; judge < 5; judge++)
{
cout << "Enter Judge " << judge << " Score ";
cin >> P1;
score1 += P1;
judge++;

while (P1 < 1 || P1 > 10)
{
cout << "Invalid Entry! Score Must Be Between < 1 - 10 >" << endl;
cout << "Enter Judge 1 Score ";
cin >> P1;
}

cout << "Enter Judge " << judge << " Score ";
cin >> P2;
score2 += P2;
judge++;

while (P2 < 1 || P2 > 10)
{
cout << "Invalid Entry! Score Must Be Between < 1 - 10 >" << endl;
cout << "Enter Judge 2 Score ";
cin >> P2;
}

cout << "Enter Judge " << judge << " Score ";
cin >> P3;
score3 += P3;
judge++;

while (P3 < 1 || P3 > 10)
{
cout << "Invalid Entry! Score Must Be Between < 1 - 10 >" << endl;
cout << "Enter Judge 3 Score ";
cin >> P3;
}

cout << "Enter Judge " << judge << " Score ";
cin >> P4;
score4 += P4;
judge++;

while (P4 < 1 || P4 > 10)
{
cout << "Invalid Entry! Score Must Be Between < 1 - 10 >" << endl;
cout << "Enter Judge 4 Score ";
cin >> P4;
}

cout << "Enter Judge " << judge << " Score ";
cin >> P5;
score5 += P5;
judge++;

while (P5 < 1 || P5 > 10)
{
cout << "Invalid Entry! Score Must Be Between < 1 - 10 >" << endl;
cout << "Enter Judge 5 Score ";
cin >> P5;
}

}
cout << " " << endl;
cout << " " << endl;
cout << "Enter The Name of The Contestant, If There Are No More Contestants Enter Done" << endl;
cin >> name;
cout << " " << endl;
}

// Creating A Way To Exit Loop With The Word "Done" And Initializing Function To Variables
while (name != "done");
double average = calcavg_Score(score1, score2, score3, score4, score5);
cout << average << endl;




system("pause");
}


// Creating Fuction calavg_Score For Return Value
double calcavg_Score(double score1, double score2, double score3, double score4, double score5)
{
double sum = (score1 + score2 + score3 + score4 + score5) -
(find_Highest(score1, score2, score3, score4, score5)+ find_Lowest(score1, score2, score3, score4, score5));
double average = (sum / 3.0);
return average;

}
next time on, try using [cOde] [/code]
(small case 'o')

Oh and, storing the name and score together would be best done with structures. Are you allowed to use those?
As far as I know can you provide an example ?
for one you can just use the format buttons on the right of the reply box...




Last edited on
next time on, try using [cOde] [/code]
(small case 'o' ^ )
...... He had to type an uppercase o bc it wouldn't print the context if he didn't change the case. Other wise it would print like this This
Last edited on
And what about a struct? The only problem is you would have to, probably, make an array of structs to keep up with all of the structures of data.
1
2
3
4
5
6
struct contInfoType
{
    string name;
    int contestantIn;
    double score;
};


But then to keep up with all of the contestants info you be better off to create an array of the struct type like so:

1
2
numberOfContestants = 10;
contInfoType yourArray[numberOfContestants];


Then you could sort the contents of the array by the name of the contestant or by the score.

Last edited on
Topic archived. No new replies allowed.