I am totally lost on this intro to computer science assignment..can someone guid
ID: 3623546 • Letter: I
Question
I am totally lost on this intro to computer science assignment..can someone guide me through this? Here is the assignment:The program will loop, asking the user for a bet amount from 0 to 100 (assume dollars, you can use ints or longs). If the user types a 0 that means he/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 determined randomly with equal probability: there is 1/4 or 25% chance of any one of the four in any position (this is where you need the rand() function).
The following combinations should pay the bet as shown (note ORDER MATTERS):
cherries [not cherries] [any] pays 3 x bet (3 times the bet)
cherries cherries [not cherries] pays 10 x bet
cherries cherries cherries pays 20 x bet
BAR BAR BAR pays 35 x the bet
7 7 7 pays 50 x the bet
After the pull, display the three strings. 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.
You will have to use methods as follows to get credit for this assignment:
int GetBet() prompts the the user for input and returns the bet amount as a functional return.
string PullOne() returns a random string from the four possibilities as a functional return (not a parameter change!) It is called by the client (your main()) three times to generate the three Strings.
int GetPayMultiplier(string s1, string s2, string s3) computes the multiplier 3, 10, etc from the above table. It returns this value as a functional return. This would be called from your client (main()) after PullOne() has been called three times to generate three strings which would be passed to this method. Note that it does not compute cash winnings but only the pay multiplier.
void Display(string s1, string s2, string s3, int winnings) will display the result of the pull and report the winnings. Winnings should be pre-computed by main() before calling this method using the value from GetBet() and the value from GetPayMultiplier(). Display() merely reports this number (after showing the pull strings). If there are no winnings, the client should pass a 0 as an argument to Display() and Display() should tell the user "Sorry", not something like "You won 0 dollars."
Communicate all values as parameters or return values, not through globals. The meaning of these terms and examples are contained in the module reading.
Also, I will emphasize that in keeping with the separation of I/O and computation, we would not have any method other than Display() output results to the screen, and Display() is called from main(), not from any other method. Similarly, GetBet() is the only method that does input. The other methods, PullOne() and GetPayMultiplier() do no input, no output and do not call any methods that do input or output. Let's keep that idea fresh as we learn new tools like methods and classes.
Provide a minimum of 10 "pulls" in your run to demonstrate that the results are adequately random and you are paying out the correct amount.
Position counts! If you read the above bullet that contains the warning "ORDER MATTERS", you will see that cherries bar cherries pays 3x while cherries cherries bar pays 10x and bar cherries cherries pays nothing.
Explanation / Answer
rs The only place the user can make an input error is in getBet(), so that's the method that deals with such errors. Don't worry about non-numbers. Assume that a number was entered
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.