Project #29197 - Introduction to Programming

Objectives:

  1. To practice using various control structures such as if, if/else, if/else/else, while, do-while, and switch.

  2. To practice standard string input and output.

  3. To create and implement your first menu.

  4. To learn how to generate a random number.

Background:

Roulette, or "small wheel" in French, is a very simple game developed in France. The wheel is divided into 38 slotted sectors, each of which is labeled with a unique red or black number ranging from 1 to 36. The remaining two slotted sectors are green and are labeled 0 (zero) and 00 (double zero). These numbers and their corresponding colors are also represented on a table used for betting. Once bets are made, the roulette wheel is spun. A small ball spirals in the opposite direction down towards the edge of the spinning roulette wheel. Once it hits the edge, the ball bounces in and out of the slotted sectors until it eventually settles inside of one of the sectors. The object of the game is to correctly guess the color (red or black), the parity (even or odd), and/or the value of the number of the slot where the ball finally lands. There are a variety of bets that can be made simultaneously in a roulette game. We will only focus on the following types of bets:

Bet Type How to win Payout

page1image15712

Even Bet

The ball lands on an even number (not 0 or 00).

page1image19136

1 to 1

Odd Bet

The ball lands on an odd number.

page1image24416
page1image24960

1 to 1

Straight Up Bet

page1image28480

The ball lands on the number you bet on.

35 to 1

page1image33824

Scenario:

Las Vegas was very pleased with your chip converter project. They want to hire you again for a more interesting job. Your task is to create a simple roulette program. Your program should allow the user to bet in a variety of ways, to spin the wheel, or to quit. The user may bet in several different ways before the wheel is spun. However, the user is not allowed to bet the same bet more than once per wheel spin. For example, the user can bet an even bet, and odd bet, and a straight up bet all for the same spin. However, once a player makes a bet, the player cannot place another bet of that same type until the next spin.

Directions:

Create a project called “Hw4” in your solution called “Homework” using Microsoft Visual Studio. The source file inside the project should be named Roulette.cpp and should contain the following header:

/*

<Your Name>
ID: <Your Student ID>
Email: <Your Email Address> Section: <Your Section # eg 2A> Honesty Pledge:

I, <Your Name Here>, pledge that this is my own independent work, which conforms to the guidelines of academic honesty as described in the course syllabus.

List of known bugs: <Known bugs, if any> */

Your code should do the following:

1. Define constants instead of using magic numbers for

  • the QUIT char (value 'q')

  • the MAX_NUMBER (value 37) on the roulette wheel

  • the DOUBLE_ZERO (value MAX_NUMBER)

  • the DEFAULT_PLAYER_NUMBER (value MAX_NUMBER + 1)

  • the EVEN_ODD_PAYOUT (value 1)

  • the STRAIGHT_UP_PAYOUT (value 35)

PIC 10A Intro. to Programming Spring 2014
Assignment #4

2. Prompt the player for his or her name and read it from the keyboard using getline.

3. Give the player an initial purse of $1000 and display the following menu:

page3image2672

4. If the user enters a bad bet, your program should behave exactly as in the following screenshot:

page4image1832

5. If the user enters a good bet and then tries to bet using the same option before the next spin, your program should behave exactly as in the following screenshot:

page5image2456
  1. The user should be able to bet an even bet or any other type of bet not yet made before the wheel spins. A bet should be subtracted from the player’s purse when made if it can be made and if the player has enough money to cover it.

  2. The "Straight Up" bet requires the user to enter a valid roulette number, your program should check if that number is valid and store it in a variable if valid. Your program should behave exactly as in the following screenshot:

    The user cannot bet on more than one number per spin "straight up style".

page6image6256

8. The user finally spins the wheel. To "spin the wheel", you need to generate a random integer between 0 and MAX_NUMBER inclusive. To accomplish this, you must first (and only once) initialize C++ random number seed, a value that will be used to generate the random numbers returned by the rand function. A good value to give the random number seed is the current time. Our program should behave exactly as in the following screenshot:

page7image4672

After a spin, display the winning number and any winning bets (even if bet value is 0). You must update the player’s purse for any winning bets according to the payout rate for each bet. You must also reset all the bet values to 0 and the player's number to DEFAULT_PLAYER_NUMBER, a value which deliberately lies out of range of possible winning numbers. This prevents the player from accidentally winning straight up the next time the wheel is spun.

9. The game should quit when the user enters 'q':

Be sure to comment your code well.

Be sure to upload your solution source code file Roulette.cpp using the CCLE website.

Make sure you check to see if your program was submitted correctly.

page8image3368

Grade Breakdown:

page9image1504

Criteria

Description

page9image6344

Points

Header

Name, UID, Username, Email, Section, Assignment #, Honesty Pledge, etc.

1

Comments

Program commented well.

1

page9image18720
page9image19264

Constants

Use instead of magic numbers

1

Appearance

Correct menu displayed.

2

Functionality

Correct action taken for each menu option.

4

Error Handling

Value range checking for bets and roulette number guess.

3

Error Handling

Cannot enter same type of bet more than once before the next spin.

3

Functionality

Correct bet amount subtracted from player purse and correct payout for each winning bet.

5

Total

page9image52328
 

20

page9image56168
page9image56600

A penalty of 5 points will be assessed if your code does not compile using Microsoft Visual Studio 2012. 

Subject Computer
Due By (Pacific Time) 04/28/2014 10:00 am
Report DMCA
TutorRating
pallavi

Chat Now!

out of 1971 reviews
More..
amosmm

Chat Now!

out of 766 reviews
More..
PhyzKyd

Chat Now!

out of 1164 reviews
More..
rajdeep77

Chat Now!

out of 721 reviews
More..
sctys

Chat Now!

out of 1600 reviews
More..
sharadgreen

Chat Now!

out of 770 reviews
More..
topnotcher

Chat Now!

out of 766 reviews
More..
XXXIAO

Chat Now!

out of 680 reviews
More..
All Rights Reserved. Copyright by AceMyHW.com - Copyright Policy