Hello, im doing a project and need some help.

my project is have to make a program for 5 judges. at the start the first thing asked is how many competitors are there.

then it asks the first judge what hes gives for the first competitior, then what the second judge gives him and so on.

then it goes on to the next competitior until they are all done.

the scores from the judges can only be from 0.0 to 6.0, and they are a float.

also the program cannot end unless it is told so, so end program Y/N and if n it will ask that again. if N then it will close.

The five scores for each judge must be averaged after their five results. so i remove the highest and lowest and then muliply the other three by 3.

my main problem is that i can do the program for 1 competitor, but if i repeat that for as many competitors for the amount that the user puts in how would i make it that they make sperate varibales and not get mixed up?

heres what i have so far and its working.

``````#include<iostream.h>
#include<conio.h>

int main()
{

float judge1high, judge1secondhigh, judge1thirdhigh, judge1forthhigh, judge1low, judge1average;
float judge2high, judge2secondhigh, judge2thirdhigh, judge2forthhigh, judge2low, judge2average;
float judge3high, judge3secondhigh, judge3thirdhigh, judge3forthhigh, judge3low, judge3average;
float judge4high, judge4secondhigh, judge4thirdhigh, judge4forthhigh, judge4low, judge4average;
float judge5high, judge5secondhigh, judge5thirdhigh, judge5forthhigh, judge5low, judge5average;
float total;

cout<<"\n\n\t\t\t\t==================";
cout<<"\n\n\t\t\t\tOLYMPIC GAMES 2012";
cout<<"\n\n\t\t\t\t==================";

//Judge 1

cout<<"\n\n\t\t\tJudge 1 enter highest score to lowest score: \n\n";
cin>>judge1high>>judge1secondhigh>>judge1thirdhigh>>judge1forthhigh>>judge1low;

judge1average=(judge1secondhigh+judge1thirdhigh+judge1forthhigh)/3.0;

cout<<"\n\n\t\t\tThe average for judge 1 is: "<<judge1average;

//judge 2
cout<<"\n\n\t\t\tJudge 2 enter highest score to lowest score: \n\n";
cin>>judge2high>>judge2secondhigh>>judge2thirdhigh>>judge2forthhigh>>judge2low;

judge2average=(judge2secondhigh+judge2thirdhigh+judge2forthhigh)/3.0;

cout<<"\n\n\t\t\tThe average for judge 2 is: "<<judge2average;

//judge 3
cout<<"\n\n\t\t\tJudge 3 enter highest score to lowest score: \n\n";
cin>>judge3high>>judge3secondhigh>>judge3thirdhigh>>judge3forthhigh>>judge3low;

judge3average=(judge3secondhigh+judge3thirdhigh+judge3forthhigh)/3.0;

cout<<"\n\n\t\t\tThe average for judge 3 is: "<<judge3average;

//Judge 4
cout<<"\n\n\t\t\tJudge 4 enter highest score to lowest score: \n\n";
cin>>judge4high>>judge4secondhigh>>judge4thirdhigh>>judge4forthhigh>>judge4low;

judge4average=(judge4secondhigh+judge4thirdhigh+judge4forthhigh)/3.0;

cout<<"\n\n\t\t\tThe average for judge 4 is: "<<judge4average;

//judge 5

cout<<"\n\n\t\t\tJudge 5 enter highest score to lowest score: \n\n";
cin>>judge5high>>judge5secondhigh>>judge5thirdhigh>>judge5forthhigh>>judge5low;

judge5average=(judge5secondhigh+judge5thirdhigh+judge5forthhigh)/3.0;

cout<<"\n\n\t\t\tThe average for judge 5 is: "<<judge5average;

total=(judge1average+judge2average+judge3average+judge4average+judge5average);

cout<<"\n\n\n\n\n\t\tThe total for this competitor is "<<total;

cout<<"\n\n\n\n\n\t\t\t Press any key to continue";
getch();
return 0;
}``````

Edited by Nick Evan: Add code-tags

2
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by dkalita

that is not a way how u should proceed declaring so many variables with similar meaning.
This is where people uses array.
Use a 2D float array to store your scores. Use another array for storing the averages.

e.g.

``````float judge_score[5][5];
float judge_avg[5];``````

We didnt do arrays yet, so i know nothing about them, could you show how you would do the project with arrays, because i would find it easier to understand then

``````int main()
{
float judge_score[5][5];/*array for storing the scores*/
float judge_avg[5];/*array for storing averages*/

int i, j;
float sum, total = 0;
/*Read judge score and calc avg*/
for(i=0;i<5;i++)/*for 5 judge*/
{
//FOR JUDGE i
cout<<"\nJudge:"<<i<<" enter scores:";
sum = 0.0;
for(j=0;j<5;j++)/*for 5 scores of each judge*/
{
cin>>judge_score[i][j];   //j'th score of judge i
sum = sum+judge_score[i][j];
}
//calculate avg for judge i
judge_avg[i] = sum/5.0;
total = total + judge_avg[i];
}
cout<<"Total score:"<< total;
return 0;
}``````

Edited by dkalita: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.