if/else error - expected a statement
Hey All,
I am fairly new to C++ and having trouble with the code below. It is giving me an error in my if/else statement. It is telling me that it is expecting a statement? For all of you who have some ideas, please let me know.
Code:
#include <stdio.h>
#include <Windows.h>
#include <iostream>
#include <string.h>
#include <time.h>
using namespace std;
int cash = 100;
void Play(int bet)
{
char C[3] = { 'J', 'Q', 'K' };
cout << "Shuffling...\n";
srand(time(NULL));
for (int i = 0; i < 5; i++)
{
int x = rand() % 3;
int y = rand() % 3;
int temp = C[x];
C[x] = C[y];
C[y] = temp;
}
int playerGuess;
Sleep(1500);
do
{
cout << "What is the position of the Queen - 1, 2, or 3? "; cin >> playerGuess;
} while (playerGuess < 1 || playerGuess > 3);
if (C[playerGuess - 1] == 'Q');
{
cash += 3 * bet;
cout << "You win! Result: " << C[0] << " " << C[1] << " " << C[2] << "!\nCurrent Cash: $" << cash << endl;
}
else //*********************************************************expected a statement error
{
cash -= bet;
cout << "You lose! Result: " << C[0] << " " << C[1] << " " << C[2] << "!\nCurrent Cash: $" << cash << endl;
}
}
int main()
{
cout << "Welcome to Virtual Casino!\n";
cout << "Total Cash: $" << cash << endl;
int bet;
while (cash > 0)
{
cout << "What is your bet? $"; cin >> bet;
if (bet == 0 || bet > cash) break;
Play(bet);
}
}