I'm writing a program where the user has 6 chances to guess a random number, but I cannot think of another way to write the code so that if the user gets the number right on the 6th try, it will say the user won. Currently even if the user gets the number right on the 6th try it still says the user lost. I cannot think of another way to write the code, any suggestions?
ETA: This is all that can be in the function. CalcMoney only calculates the amount he user has. A different function determines if the user won or not, which is part of why i'm having trouble.
This is the function it's in:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
int CalcMoney (int amountWon, int betAmount, int guessNum)
{
if (guessNum == 6)
{
cout << "You lost $" << betAmount << endl;
amountWon = (-betAmount);
}
elseif (guessNum < 6)
{
amountWon = betAmount / guessNum;
cout << "You just won $" << amountWon << endl;
}
return amountWon;
}