logo CodeStepByStep logo

Roulette

Related Links:

Write a console program in a class named Roulette 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 36, money = $1
bet $1, spin 22, money = $0
max = $16

You should break down your program into several methods, each of which helps solve the overall problem. (Because this program uses random numbers, our site cannot perfectly verify its behavior; we will look to see that you have the right overall output format, but it is up to you to verify whether you are handling the spin/money logic correctly.)

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.