How to output The "Winner" ?

I am currently in the process of writing a program.
A quick summary of what i need to do :

A game called Dorax, the aim of the game is for players to throw a weighted ball to a target 50metres away, with each player playing 3 times. The aim to reach 50meters as close as poss. The player begins each round with 20 points, one point is deducted for each throw the player makes and a further 1 point for each full meter the ball lands over the target of 50.

Im having trouble outputting the winner and their score, It is out putting the last player who has played as the winner


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


int main () {

//Variables

string name,winner;
int distance=0, distance2=0, distance3=0, totalover,totalsumofthrow, score, totalscore=0;
char choice, get_outof_loop, results_choice,choice2,ch;
int amountOfThrows=0, amountOfThrows2=0, amountOfThrows3=0, sumAllThrows3=0, sumAllThrows=0, sumAllThrows2=0;
int total,over=0,total2, over2=0, total3, over3=0;
char round_choice;
int round =0, points=60,highest=0;



cout<<"Would you like to Play Dorax? "<<endl;
cin>>choice;

while (choice=='y')

{//Start of While
int sumAllThrows=0;

cout<<"Round: 1"<<endl;
cout<<"Please enter players name: "<<endl;
cin>>name;

cout << "Please enter the distance thrown: " << endl;
cin >> distance;
sumAllThrows+=distance;
amountOfThrows++;


while (sumAllThrows < 50)

{//Start of While
cout << "Please enter the distance thrown: " << endl;
cin >> distance;
sumAllThrows+=distance;
amountOfThrows++;
}//End of While


if (sumAllThrows > 50)

{//Start of If

cout<<"End of Round, you exceeded 50"<<endl;
over=sumAllThrows - 50;
cout<<"you went over by: "<<over<<endl;
cout<<"Would you like to proceed to the next round? "<<endl;
cin>>round_choice;

}//End of If


if (round_choice == 'y' || round_choice == 'Y')

{ //Satert of if
int sumAllThrows2=0;

cout<<"Round: 2"<<endl;
cout << "Please enter the distance thrown: " << endl;
cin >> distance2;
sumAllThrows2+=distance2;
amountOfThrows++;

while (sumAllThrows2 < 50)

{//Start of While
cout << "Please enter the distance thrown: " << endl;
cin >> distance2;
sumAllThrows2+=distance2;
amountOfThrows++;
}//End of While


if (sumAllThrows2 > 50)

{//Start of If
cout<<"End of Round, you exceeded 50"<<endl;
over2=sumAllThrows2 - 50;
cout<<"you went over by: "<<over2<<endl;
cout<<"Would you like to proceed to the next round? "<<endl;
cin>>round_choice;
}//End of If
}//End of If


if (round_choice == 'y' || round_choice == 'Y')

{//Start of If
int sumAllThrows3=0;
cout<<"Round: 3"<<endl;
cout << "Please enter the distance thrown: " << endl;
cin >> distance3;
sumAllThrows3+=distance3;
amountOfThrows++;

while (sumAllThrows3 < 50)

{//Start of While
cout << "Please enter the distance thrown: " << endl;
cin >> distance3;
sumAllThrows3+=distance3;
amountOfThrows++;
} //End of While

if (sumAllThrows3 > 50) ;
{//Start of If

cout<<"End of Game, you exceeded 50"<<endl;
over3=sumAllThrows3 - 50;
cout<<"you went over by: "<<over3<<endl;



totalsumofthrow=sumAllThrows+sumAllThrows2+sumAllThrows3;
totalover=over+over2+over3;
score=points-amountOfThrows;
totalscore += score - totalover;





if (totalscore>highest)
{ //Start of If

winner=name;

}

cout<<"A for all results,y for new layer, r for your result?"<<endl;
cin>>choice;

if (choice=='a')

{
cout<<"winner is"<<winner<<endl;
}

}//End of If
}//End of If
}//End of Main Loop



getch ();
return 0;
}//End of rogram
Last edited on
Topic archived. No new replies allowed.