Here's what Im trying to do...
Write a program that asks the user to guess the next roll of a six sided die. Each guess costs $ 1. If they guess correctly, they get $ 100.00. The player will start out with a $10.00 bank. Each time he (or she) guesses incorrectly you will subtract $1.00 from their bank. Each time they guess correct, you add $100.00 to their bank. Print the total winnings or loss at the end of the game. [Each die toss is simulated using die = (int)(rand() % 6) + 1;]
program should look something like this:
Your bank is $10.00
Please enter your guess for the next roll. It only costs $1.00 to play, If you are correct I will pay you $100.00:
6
Sorry, the dice rolled a 5.
continue?
y
Your bank is $9.00
Please enter your guess for the next roll. It only costs $1.00 to play, If you are correct I will pay you $100.00:
4
Winner! the dice rolled a 4.
continue?
n
Thanks for playing your bank is $109.00. Come back real soon
here's the code I have so far, what am I doing wrong?
#include <iostream>
using namespace std;
int main()
{
int bank = 10;
int dice = (int)(rand() % 6) + 1;
int guess;
char answer;
cout<< "Welcome to my casino, Your bank is $10.00, Correctly guess what number will roll next.If you guess right you will $100.00 " << endl;
cout<< "It only cost one dollar to begin " << endl;
cout<< " Do you want to play Y or N? " <<endl;
cin>>answer;
while (answer = 'Y')
{
cout<< "Please enter your guess " << endl;
cin>>guess;
cout<<endl;
break;
if (guess !=dice)
{
cout<< "Sorry you are wrong, you have: " << bank-1<< endl;
cout<< " would you like to play again? " << endl;
}
if (guess = dice)
{
cout<<"congradulations you have won 100!! you now have " <<bank + 100<<endl;
cout<< " would you like to play again" << endl;
cin>> answer;
}
}
cout<<endl;
return 0;
}