Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ program to simulate the spin and ball landing on the number of a roulette wheel. .A roulette wheel consists of 38 possible

Write a C++ program to simulate the spin and ball landing on the number of a roulette wheel.

.A roulette wheel consists of 38 possible numbers with colors assigned to each. The numbers range from

0-36 (inclusive) plus a 00. The color assignment is as follows:

1-10, 19-28 -> odd numbers are red, even are black

11-18, 29-36 -> odd numbers are black, even are red

0,00 -> are green and not considered odd or even

Our goal is to write one class to simulate the spin and one to test it.

The spin function must return the following information for each spin

(looks like a great use of a struct):-

the number (hint - you could #define 37 to equal 00)

- if it is red, black, or green

- if it is even, odd, or not

- if it is Manque (1-18), Passe(19-36), neither

This class should also contain an initialize method to setup anything that might be needed.

You also need to write a class to test your spinner. This class should test that the spread of numbers

generated (%occurrence) match with what is expected (statistically use 1000000 runs). It also needs to check

the distribution of red/black/green, even/odd/not, Manque/Pass, and finally that each run does not contain the same sequence of numbers (checking the first 10 numbers 10 times in a row should be enough). The results of these tests need to be well formatted and written to a file (using a separate function within this class) containing the information below. Note: You should use .3% as your tolerance value.

Example file

(bold would actually be in the file]

:

Random Number Generation: Pass (this test would be for the sequence of numbers (first 10-10x))

Number Of Iterations: 1000000

Number Generation Tests:

Test Actual% Expected% Pass/Fail

00 2.34 2.60 Pass

0 1.90 2.60 Fail

Even ...... ........ ...... (Obviously with real numbers, not .....)

......and so on for each number and then for the rest (Even, Odd, Red, etc.)

The final line should have the following (should be a fail if any test fails, or pass otherwise):

Overall Test Result: Fail

Make sure you use header files for all classes (except main) and make functions that should be public, public (and private ones, private). Also, for Red/Black/Green (as well as others) use an enum.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

LOQ 14-19: What criticisms have social-cognitive theories faced?

Answered: 1 week ago

Question

Identify cultural barriers to communication.

Answered: 1 week ago