Professional Documents
Culture Documents
Efren Martinez
Description
For this assignment we are playing a betting game. The user starts off with a starting amount. Then is asked
the amount they wish to bet. They then try to guess what hole the cheese is in. If they choose correctly the
user wins double his bet amount. If they lose they lose the bet amount. The game keeps going till the user
decides to quit or the user has $0.
The Code
cout << "How much do you want to bet?: " << endl;
cin >> bet_amount;
cout << "Invalid amount. Enter new amount: " << endl;
cin.clear();
cin.ignore();
}
cout << endl;
srand(time(NULL));
mouse_location = rand() % 3 + 1;
cout << "There are three rat holes, one has the cheese" << endl;
cout << "What hole is the cheese in? Type 1 for right, 2 for center and 3 for right:" << endl;
cin.clear();
cin.ignore();
if (user_guess == mouse_location) {
else {
cout << "Wrong guess :(" << endl;
if (inhand_cash <= 0) {
exit(1);
cout << "Amount in hand: $" << setprecision(5) << inhand_cash << endl;
cout << "Do you want to play again? Type 'y' for yes or 'n' for no: " << endl;
cout << "Game over" << endl << "You're ending amount: $" << inhand_cash << endl;
The output
Screenshots of your runs.
Comments/Notes (Extra Credit)
The comments or the notes section is if you wanted extra credit. This could be struggles you have come
over while doing your program, or additions you wanted to highlight so I notice while grading…