Due dates:

Getting Started

Start by downloading CS101_Assign04.zip, saving it in the directory H:\CS101.

Start a Cygwin Bash Shell and run the following commands:

cd h:
cd CS101
unzip CS101_Assign04.zip
cd CS101_Assign04

Using Notepad++, open the file

H:\CS101\CS101_Assign04\Roulette.cpp

You will add your code to this file.

When you are ready to compile the program, in the Cygwin window type the command

make

To run the program, type the command

./Roulette.exe

Your Task

The program should prompt the user to enter the initial amount of money they are starting with, obtain a bet amount and the bet type, then spin of the wheel to determine whether the user won or lost updating the user’s account. The user should then be prompted to play again until they chose to quit or run out of money.

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 (user input in bold):

Enter the amount of money you are starting with: $ 100

Enter your bet: $ 3

How do you wish to bet?
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: 1

Enter your bet: $ 4

How do you wish to bet?
1 To bet on Odd
2 To bet on Even
3 To bet on a Particular Number

2

The ball landed on 16.
That's even, you win $4.00

Your total winnings are $1.00
Your current account is $101.00

Enter 0 to Quit, 1 to Continue: 1

Enter your bet: $ 3

How do you wish to bet?
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: 0

Thank you for playing Roulette.

Roulette Functions

Your program MUST use the following functions:

Approach/Hints

Main

Consider how to design the program to utilize the functions. Main() should only

Function declarations

Consider the data types for each parameter and the return type of each function. Write each function as a standalone routine. Be sure to add function prototypes before main().

Spinning the wheel

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

srand(time(0));

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

Grading

Your grade will be determined as follows:

We expect you to use good coding style. Points may be deducted for poor variable names, inconsistent or missing indentation, and/or lack of comments.

Submitting

To submit your code, make sure your Roulette.cpp file is saved, and in the Cygwin window type

make submit

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.

If the make commands above do not work, you can submit using the web interface (see the link for details).

Make sure that you check the file(s) you submitted to ensure that they are correct. See the instructions for Verifying your submission.