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

  The game of life

The game of Life, invented by the mathematician John H. Conway, is intended to model life in a society of organisms. Consider a rectangular array of cells, each of which may contain an organism

  You are to create a text adventure game that uses pointers

you are to create a text adventure game that uses pointers. you have a rich eccentric uncle billy who is soon to be

  Sum of all non-inherited data members

show on the console the sum of all non-inherited data members of every instance in the program by Display() function

  Local resturant automate its breakfast billing system

Use an array , menuList, of the struct menuItemType. use an array, menuList, of the struct menuItemType. your program must contain at least the following functipons : your program must contain at least the following functipons.

  Write code in a client program

prompt use to enter a name and read it from the standard input device.

  Find the amount in the savings act each month

Suppose you start with $1000 and each month you contribute $100. suppose that the interest rate is 6%per year compounding monthy,which is equal to 0.5% each month.

  Define a function hypotenuse that calculates the hypotenuse

Define a function hypotenuse that calculates the hypotenuse of a right triangle when the other two sides are given. The function should take two arguments and return the hypotenuse as a double.

  Compare and contrast the mode operators ios

Compare and contrast the mode operators ios::in, ios::app, and ios::out. Provide a C++ code segment that illustrates the use of these mode operators.

  Dimensional array of integers and fill it with data

Create a 2-by-3 two-dimensional array of integers and fill it with data. Loop through the array and locate the smallest value stored. Print out the smallest value as well as its row and column position in the array

  Write the pseudo code for a subprogram called summer

Write the pseudo code for a subprogram called summer (and only the subprogram) which has three parameters: A two dimensional array of integers which is changed by summer and sent back

  You will write a program that reads a text file

You will write a program that reads a text file, counts the number of words in the file, and the number of occurrences of each character. It will print to a file the number of words, and the number of occurrences of each character, as well as the ..

  Assume we have an array named $students

Assume we have an array named $students. Each entry in the array contains a student's full name (e.g. "Jane Smith"). Write the PHP code needed to display all students (in the array) whose first name starts with the letter "J".

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