Investigate the use of the random generator function

Assignment Help C/C++ Programming
Reference no: EM13813187

For this assignment you will have to investigate the use of the C++ random generator function, rand(). Rand() produces a random integer in the range of 0 to RAND_MAX (a constant -- often 32767 -- defined in the stdlib, automatically included in all of your projects). You can find this in the text or using the online resources given in the lectures.

OPTION A (Basic) A Slot Machine Simulation

Understand the Application

What it Looks Like to the User

The program will loop, asking the user for a bet amount from 0 to 50 (assume dollars, you can use ints or longs). If the user types a 0 that means she wants to quit. Otherwise, accept the amount as their bet and simulate a slot machine pull. Your program will print out a line that looks like a slot machine result containing three strings. Some examples are: BAR 7 BAR, 7 7 cherries, cherries BAR space, space BAR BAR, or cherries cherries BAR.

Each of the three positions in the string could be one of the following: "BAR", "7", "cherries" or "space".

Each of the three output positions is must be generated by your program randomly with probabilities:

BAR (40%)

cherries (30%)

space (5%)

7 (25%)

Therefore, BAR should be the most frequent symbol seen and space or 7 the least frequent.

The following combinations should pay the bet as shown (note ORDER MATTERS):

cherries [not cherries] [any] pays 5 × bet (5 times the bet)

cherries cherries [not cherries] pays 15 × bet

cherries cherries cherries pays 30 × bet

BAR BAR BARpays 50 × bet

7 7 7 pays 100 × bet

After the pull, display the three strings regardless of the outcome. If the user did not win, tell him/her "Sorry, you lose." If he won, pay him by displaying his winnings (his original bet times the winning factor from the above table). Then, repeat the whole process by requesting another bet amount.

Reference no: EM13813187

Questions Cloud

Who would be involved in idea-generating sessions : Identify some core values of this organization as best as you can. What do they believe in (beyond organizational success or profitability)?
Develop a health organization disaster planning : Develop a Health Organization Disaster Planning and Response Strategy that links federal, state, and local agency authorities and reflects the potential ethical decision-making that a health care leader may be confronted with.
What are the four supply factors of economic growth : What are the four supply factors of economic growth? What is the demand factor? What is the efficiency factor?
Write about how using cell phones while driving is dangerous : Write a paper about How using cell phones while driving is dangerous?
Investigate the use of the random generator function : For this assignment you will have to investigate the use of the C++ random generator function, rand(). Rand() produces a random integer in the range of 0 to RAND_MAX (a constant -- often 32767 -- defined in the stdlib, automatically included in al..
Key deliverables associated with the selected project : Describe the five phases of a project. Describe the key deliverables associated with the selected project(s).
Identify the main problem your audience is facing : Identify the main problem your audience is facing and which you are proposing to solve. You are writing for a relatively small business owner who is trying to decide whether or not to move to cloud computing.
Decisions of the federal open market committee : You should now find a press release from the Board of Governors of the Federal Reserve System, dated December 16, 2009, which discusses the decisions of the Federal Open Market Committee (FOMC) for that date
Who defended the british soldiers during the boston massacre : Who defended the british soldiers during the boston massacre?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write a program that keeps track of important birthdays

Write a program that keeps track of important birthdays. You can implement it with a one-dimensional array with enumeration type indices, a two-dimensional array, or with parallel arrays.

  Write a program in c tonbspreverse the order of elements on

write a program in c tonbspreverse the order of elements on a stack s using two additional stacks using one additional

  Disadvantages of designing an abstract data type

What are the disadvantages of designing an abstract data type to be a pointer and explain the dangers of C's approach to encapsulation.

  What is output from the following segment of code

What is output from the following segment of code? (note: this is a code segment, not a complete program.) What is output from the following code segment

  Draws a pyramid consisting of bricks

Write a C program that draws a pyramid consisting of bricks arranged in horizontal rows, so that the number of bricks in each row decreases by one as you move up the pyramid.

  This project is to develop a program that implements a

this project is to develop a program that implements a hierarchical jpeg encoderdecoder for greyscale images.write your

  Explain how to convert c program to mips program

Convert the following C program to MIPS program. Assuming that i, j, k, f, are stored in registers $s0, $s1, $s2, $s3 already.

  Write a hexadecimal integer literal

Write a hexadecimal integer literal representing the value fifteen.

  Coinflip to prompt for and input a number

Write a program and name it CoinFlip to prompt for and input a number of times to flip a coin, then to output the number of "heads" and the number of "tails" that were flipped.

  Explain how to represent a lagged fibonacci generator

Explain how to represent a lagged Fibonacci generator using list abstract data types. What representation would be the most appropriate?

  Write a function to convert the two dimensional coordinates

Write a function to convert the two dimensional coordinates of a point from Cartesian system to polar system by using x and y as its parameters, returning r and using references to pass theta value.

  Guessing game

In C++ develop a "guessing game" where the computer and the user alternatively guess the value of a randomly selected secret number between 1 and 99 (or any other maximum value). Initially, the computer selects the random number, and the user make..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd