logo CodeStepByStep logo

roulette

Related Links:

Write a console program that simulates the gambling game of Roulette, with the following characteristics. The player begins with $10 and bets (up to) $3 per spin of the wheel. If the wheel comes up 1-18, the player wins $3. Otherwise, player loses $3. Play until the player gets $1000 or drops to $0. At the end, print the max money the player ever earned. Here is an example dialogue:

bet 3 spin 15 money 13
bet 3 spin 35 money 10
bet 3 spin 7 money 13
bet 3 spin 4 money 16
bet 3 spin 28 money 13
bet 3 spin 19 money 10
bet 3 spin 21 money 7
bet 3 spin 26 money 4
bet 3 spin 0 money 1
bet 1 spin 22 money 0
max = 16

You should break down your program into several functions, each of which helps solve the overall problem.

(Because this problem uses random numbers, our test cases check only the general format of your output. You must still examine the output yourself to make sure the answer is correct.)

Complete program: Write an entire program that you could put into a file and run outside of CodeStepByStep.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.