[ Lab1 ] [ Lab2 ] [ Lab3 ] [ lab4 ] [ lab5 ] [ lab6 ] [ Lab7 ] [ Lab8 ] [ Lab9 ] [ Lab10 ]
CP107
LAB 6
LAB OBJECTIVES:
 |
Use of Arrays |
 |
Use Loops |
 |
Use functions |
 |
Use enum operator |
 |
IO manipulators |
 |
Use relational operators and compound conditions such as and,
or , not |
 |
Use a switch statement for decision making |
 |
Use
an if statement for decision making |
LAB ASSIGNMENTS craps.cpp
Chapter 4, exercise question 4.19
Write a program that runs 1000 games of craps and answers the following
questions.
YOU MUST EXPLICTLY ANSWER THE FOLLOWING 5 QUESTIONS. EACH QUESTION IS WORTH 5
POINTS.
- How many games are won on the 1st roll, 2nd roll, ....20th roll, and
after the 20th roll?
Hint: Create an array of 22 elements, that saves number of wins on first
roll in first element of the array, wins on second roll in second element
of the array, wins on 20 th rolls in the 20th element of the array.
All "wins" that are won on 21 or more rolls, are saved in the 21
element of the array. Ignore element zero of the array.
List Number of games won on first roll, second roll ....21 th roll.
- How many games are lost on the 1st roll, 2nd roll, ....20th roll, and
after the 20th roll?
Hint: Same as #1.
- What are the chances of winning at craps? (Note: You should discover
that craps is on of the fairest casino games. (What do suppose this
means?)
Total number of wins * 100 / Total Games
- What is the average length of a game of craps?
How many times the dice was rolled, before the game ended (won or loss).
One way to do this is to keep track of total number of 'roll of dice' in
1000 games and then take an average.
- Do the chances of winning improve with the length of the game?
See chapter 3 for details an example program which is very similar to
this.
|