Question: I'm in java one and need help with this code. please follow the directions given and test your program to make sure it works as
I'm in java one and need help with this code. please follow the directions given and test your program to make sure it works as it is required. I will apreciate your help. thank you.please use the given code.
Programming Concepts
1. Random Numbers
2. Methods 3. Passing Arrays
Assignment Description
-- Write a program that will emulate a slot machine. The machine will continue to run until the user wishes to stop or runs out of money. The machine generates 3 random characters.
-- Every time the user wants to play again, subtract $1 from their total
--You will copy a template of the program from this directory into yours by issuing the following command:
cp ~lkoperski/1404_Lab/Assignments/SlotMachine.java .
here is the template. please use it as given and fill the missing information to make the program work.


Required Methods
public static void genRandSlots ( char[] slots ) o I have created a char array for you, called symbols, with an initializer list of the heart, spade,club, and diamond symbols
o For each element of the slots array, you need to randomly pick one of the symbols and store it into the slots array
public static int getWinnings( char[] slots ) o Based on the number of matching characters in the slots array, calculate the amount of money that the user wins, and return it.
o If three characters match >? The user wins $10
o If only two characters match > ? The user wins $5
o If none of the characters match > ? The user wins $0
Methods Already Written For You
public static boolean playAgain () o Asks the user if they want to play again
o Returns true if they say do o Returns false if they say don't
public static void printSlots () o Prints out the slots
Output Example 1 Getting two matching symbols
user@loki:~$ java SlotMachine
You have $3
???????
You won $0 Would you like to pay $1 to play again? ( Y / N ): y
====================================================
You have $2
???????
You won $5 Would you like to pay $1 to play again? ( Y / N ): y
====================================================
You have $6
???????
You won $0 Would you like to pay $1 to play again? ( Y / N ): n
====================================================
user@loki:~$
Output Example 2 Getting three matching symbols
user@loki:~$ java SlotMachine
You have $3
???????
You won $10 Would you like to pay $1 to play again? ( Y / N ): y
====================================================
You have $12
???????
You won $0 Would you like to pay $1 to play again? ( Y / N ): n
====================================================
user@loki:~$
Output Example 3 Running out of money
user@loki:~$ java SlotMachine
You have $3
???????
You won $0 Would you like to pay $1 to play again? ( Y / N ): y
====================================================
You have $2
???????
You won $0 Would you like to pay $1 to play again? ( Y / N ): y
====================================================
You have $1
???????
You won $0 Would you like to pay $1 to play again? ( Y / N ): y
====================================================
You failed at gambling. Call the helpline at 1-800-IAMBAD
user@loki:~$
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
