psuedocode ONLY to design a complete slot machine program. The object of the gam
ID: 3693718 • Letter: P
Question
psuedocode ONLY to design a complete slot machine program.
The object of the game is to get 2 or 3 of the same numbers out of a total of 3 digits (each digit is in the range 1-9).
The specifications are listed below.
Welcome the user with an introduction and ask how much money they want to put in the slot machine.
Ask the user how much of their money they want to bet
Generate the three digits and show them to the user (hint: you will need to generate each digit separately.)
Any 3 matching digits = Win ten 10 times your bet
Any 2 matching digits = Win 2 times your bet
Anything else = Lose your bet
Tell the user how much they won or lost and how much money they have remaining
Allow the user to play again, but only if they have money left
When the user is out of money, thank them and end the game
Make sure that you are validating the things the user is doing. For example, don't let them make a bet higher than the amount they put in the machine.
Use at least two FUNCTIONS to modularize the program
BOLD your functions so that I can clearly see them in the code
Explanation / Answer
Psuedocode
: In Main Method/Function
Step1 Print Introduction message
Step2: Declare double type variable to store Amount entered by user. Ask user for Initial Amount they want to put in machine.
Step3: check in while loop whether initial amount entered by user in 2 in greater than 0 and User want to play again(you can ask for user choice(yes/no)). If condition validates go to step 4 else print end game message and exit
While(amount>0 && choice==”yes”)
//Function
Step4: Create one function which will ask User for amount they want to bet and store it in another double amount variable and return that variable. Validate that It should not be greater than Initial amount in step 2. Otherwise call this function in loop until user do not enter correct value
While(bet_amount>amount)
{
Double function_name()
{
}
}
Step5: Declare 3 int type variables for 3 digits and use language inbuilt random generation method to generate 3 digits between 1-9 inclusive.
//Function
Step6: Declare new function with three parameters as 3 digits generated randomly in step 4. Ask user to enter 3 digits and check how many digits match with digits present in argument of function header and accordingly set the winning or losing amount and return it. i.e. if user win then return positive amount else return negative amount.
Double function_name(int digit1.int digit2,int digit3)
Example
If bet amount is say 100$ and user win 2 matches then return 200$ if no match then return -100$(note negative sign in front)
Step 7: finally in main function add the returned amount in previous step to amount entered by user in step2 and display it with some message.
Step 8: if amount is greater than 0 ask user whether he want to play more.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.