Due: Monday, February 15th by 11:59 PM
Updated Feb 10th - due date extended
Start by downloading CS101_Assign2.zip, saving it in the directory H:\CS101.
Start a Cygwin Bash Shell and run the following commands:
cd h: cd CS101 unzip CS101_Assign2.zip cd CS101_Assign2
Using Notepad++, open the file
You will add your code to this file.
Run the command
when you are ready to compile the program. To run the program, run the command
Your task is to write a program to play Roulette (except with no red or black bets).
Summary of Roulette: There are 38 slots, two green, and the rest numbered 1 through 36. If you land on green, you automatically lose your bet. If you bet odd or even and you win, you win the same amount that you bet plus you get your bet back. If you bet on a number and win, you win 35 times your bet plus you get your bet back.
Here is an example run of the program (user input in bold):
Enter the amount of money you are starting with: $ 100 Enter your bet: $ 3 Select: 1 To bet on Odd. 2 To bet on Even. 3 To bet on a Particular Number. 1 The ball landed on a green slot. Sorry, You lose $3.00 Your total winnings are -$3.00 Your current account is $97.00 Enter 0 To Quit, 1 to Continue Playing: 1 Enter your bet: $ 4 Select: 1 To bet on Odd. 2 To bet on Even. 3 To bet on a Particular Number. 1 The ball landed on 3 . That's odd, You Win $4.00 Your total winnings are $1.00 Your current account is $101.00 Enter 0 To Quit, 1 to Continue Playing: 1 Enter your bet: $ 3 Select: 1 To bet on Odd. 2 To bet on Even. 3 To bet on a Particular Number. 3 Enter the number you would like to bet on (1 - 36 only): 25 The ball landed on 19 . Sorry, You Lose $3.00 Your total winnings are -$2.00 Your current account is $98.00 Enter 0 To Quit, 1 to Continue Playing: 0
For a Grade up to 70%:
Allow the user to bet on odd or even and let the user play as many times as he/she wants. Tell the user what the ball landed on and how much he/she won.
For a Grade up to 80%:
Also keep track of the winnings and the current amount of money the user has. Report the values to the screen after each roll. When printing out the winnings and account values, use 2 decimal places and don't forget the $ sign.
For a Grade up to 90%:
Also allow the user to bet on a particular number.
For a Grade up to 100%:
In addition to the items above: Format your output so it looks nice (You will need to include spaces and/or tabs in your printf to line things up).
If the winnings are negative, put the minus sign before the dollar sign.
The program should make sure that the user enters valid input. Specifically:
- Check that the user enters a valid bet amount (it must be positive, and must not be greater than the amount in the user's account.)
- Check that the user enters a valid bet type.
- Check that the user enters an appropriate response when prompted to continue or quit.
Any time the user enters invalid input, the program should re-print the prompt and read the input again.
If the user runs out of money, let them know and end the game.
You can call slot 0 and slot 37 green and then you should have slots 1 - 36 left.
You should add the following #include directives at the top of the file:
#include <stdlib.h> #include <time.h>
Near the beginning of the statements in your main function, add the statement
This statement will seed the random number generator with a value based on the current time.
When the program simulates a spin of the roulette wheel, it can "randomly" choose an integer in the range 0 through 37 (inclusive) using the expression
rand() % 38
To submit your work, make sure your Roulette.cpp file is saved, and type the command
Enter your Marmoset username and password (which you should have received by email.) Note that your password will not be echoed to the screen. Make sure that after you enter your username and password, you see a message indicating that the submission was successful.
Important: Make sure that you check the file(s) you submitted to ensure that they are correct. Log into the server using the following URL:
You should see a list of labs and assignments. In the row for assign2, click the link labeled view. You will see a list of your submissions. Download the most recent one (which should be listed first). Verify that it contains the correct files.
You are responsible for making sure that your submission contains the correct file(s).