Programming Problem 3

This is programming problem three for C# .NET. This exercise focuses on the contents of chapters 5-7 in the Sharp and Jagger book. Basic focus is on using loops and classes to solve more complex problems.

Key Components

Loops and Iteration

Try/Catch Blocks

Classes and Objects

Information Items:

Randoms

American Roulette Wheel

Sample Output

The Sucker Bet

Basic Problem
There are always those people who believe they can win at gambling but simple statistics proves that in the long run, you will always lose at most gambling games in casino's. People base their belief in gambling on the short run winnings sometimes obtained by playing games of chance. For this problem, you need to accomplish two things: 1) Simulate what happens if a person places bets on red and black on an American Roulette Wheel. The pay off on these bets is 2 to 1 (which means if the number comes up on your colour, you win 2 dollars for every dollar you bet). The problem you are trying to prove is an old fallacy, if there are two reds in a row, then bet on the black and likewise if there are two black numbers in a row, bet on the red. So your program should simulate the bettor who watches for this to happen and then places a bet. Allow the user to simulate runs of any length (say 100, 1000, 10000, and 100000 spins of the wheel) and report back how much the person wins or loses using this system. You should allow for at least thirty repetitions of the number of spins to compute the average winnings/losses based on that run. Be sure and report how many bets were made as well since they won't bet every spin. Bets of a dollar are fine since the point is to determine how much is won or lost, you can simply multiply by 5 or whatever you would really bet to see the true outcome. 2) Develop your roulette wheel as a class which has a method that returns the number (this is a very simple class) when requested. Read the section on randoms to the left when developing your class.

Remember, this is a simulation so there is no need to show the spins, just the outcomes.

Advanced Problem

If you are bored, try this. Try implementing the application in the GUI with statistical output (maybe a graph of winnings) as the simulation is running. The more options you can allow (different systems say 3 in a row or some other roulette system) the more interesting the simulator becomes. Think about Try Catch Exception handling in your coding.


Links