Help with do-while loop please

I'm building a program for school that is supposed to be kind of like a slot machine. Except it is simulating three dice rolling, and different combinations (mostly matching numbers) yield a prize. The user should be allowed to opt out after any roll. I was hoping the do - while loop would work, but I am not able to test it because I get these lame errors, "159 C:\Users\Nathan\Desktop\main.cpp expected `;' before "else" and 159 C:\Users\Nathan\Desktop\main.cpp expected primary-expression before "else." This is the code I have so far.

//Author: Nate
//Title: The Easy Win Dice Game
/*Description: A Game that no one would ever play.*/

#include <iostream>
#include <conio.h>
#include <cstdlib>
#include <ctime>

using namespace std;

int main()
{
srand(time(0));
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
int die_1, die_2, die_3;
double starting_amount, current_amount;
char play_on;

cout<<"Welcome to the Easy Win Dice Game!\n";
cout<<"You can win either $20, $10, $2, or $0 depending on your roll\n";
cout<<"Each roll costs $2\n";
cout<<"Do you want to play?\n";
cout<<"Press 'Y then ENTER' if you are a champion\nor any other key then ENTER if you are a quitter\n";
cin>>play_on;

if ((play_on=='Y')||(play_on=='y'))
{
cout<<"You chose how much you want to start with:\n" << "$";
cin>>starting_amount;
cout<<"You Rolled:\n";
die_1=1+(rand()%6);
cout<<die_1;
cout<<", ";
die_2=1+(rand()%6);
cout<<die_2;
cout<<", and ";
die_3=1+(rand()%6);
cout<<die_3;
cout<<".";

while (die_1==die_2==die_3)
{
if (die_1==die_2==die_3&&die_1==1)
{
cout<<"\nYou won:\n";
cout<<"$20";
cout<<"\nYou now have:\n";
cout<<"$";
current_amount = (starting_amount - 2 + 20);
cout<<current_amount << endl;
}
else
{
cout<<"\nYou won:\n";
cout<<"$10";
cout<<"\nYou now have:\n";
cout<<"$";
current_amount = (starting_amount - 2 + 10);
cout<<current_amount << endl;
}
}
while (die_1==die_2 || die_1==die_3 || die_2==die_3)
{
if (die_1==die_2 || die_1==die_3 || die_2==die_3)
{
cout<<"\nYou won:\n";
cout<<"$2";
cout<<"\nYou now have:\n";
cout<<"$";
current_amount = (starting_amount);
cout<<current_amount << endl;
}

else
{
cout<<"\nYou won:\n";
cout<<"$0";
cout<<"\nYou now have:\n";
cout<<"$";
current_amount = starting_amount-2;
cout<<current_amount << endl;
}
}

cout<<"\nWould you like to play again?" <<endl;
cout<<"Yes (Y) or No (N)?" <<endl;
cin>>play_on;
}

// Repeating rolls

do{
if ((play_on=='Y')||(play_on=='y'))
{
cout<<"You Rolled:\n";
die_1=1+(rand()%6);
cout<<die_1;
cout<<", ";
die_2=1+(rand()%6);
cout<<die_2;
cout<<", and ";
die_3=1+(rand()%6);
cout<<die_3;
cout<<".";
while (die_1==die_2==die_3)
{
if (die_1==die_2==die_3&&die_1==1)
{
cout<<"\nYou won:\n";
cout<<"$20";
cout<<"\nYou now have:\n";
cout<<"$";
current_amount = (current_amount - 2 + 20);
cout<<current_amount << endl;
}
else
{
cout<<"\nYou won:\n";
cout<<"$10";
cout<<"\nYou now have:\n";
cout<<"$";
current_amount = (current_amount - 2 + 10);
cout<<current_amount << endl;
}
}
while (die_1==die_2 || die_1==die_3 || die_2==die_3)
{
if (die_1==die_2 || die_1==die_3 || die_2==die_3)
{
cout<<"\nYou won:\n";
cout<<"$2";
cout<<"\nYou now have:\n";
cout<<"$";
cout<<current_amount << endl;
}
else
{
cout<<"\nYou won:\n";
cout<<"$0";
cout<<"\nYou now have:\n";
cout<<"$";
current_amount = current_amount - 2;
cout<<current_amount << endl;
}
}

cout<<"\nWould you like to play again?" <<endl;
cout<<"Yes (Y) or No (N)?" <<endl;
cin>>play_on;
}
else
{
cout<<"Thanks for playing!";
}
}while ((play_on=='Y')||(play_on=='y'));

else
{
cout<<"\nThanks anyways :[";
}



getch();
system("\npause");
return 0;
}
Last edited on
Next time please format your text. It would be easy to find the line. I think the last else is missing an if
ok. i ended up needing a well carefully placed }. thanks for looking at it
Topic archived. No new replies allowed.