Introduction to java: Gambling
Objectives:
•Performing decisions using if and switch statements.
•Using relational and logical operators
•Working with random numbers
Write an application that simulates a gambling slot machine. Inthe application, perform the following tasks:
1. Prompt the player to enter the amount of money that theplayer is willing to gamble.
2. Create three random numbers in range from one to four torepresent three of the following four objects (Apple, Orange,Cherry and Pineapple).
3. Compare the numbers for equality and calculates the prize.oIfall three numbers are the same, the player wins three times theamount inserted.oIf two objects are the same the player wins backthe amount inserted (gets the money back), otherwise the playerwins $0.
4. Display the randomly selected objects (fruits names, notintegers). Use switch or if else statements to examine the randomlycreated integers in order to display the corresponding fruits.
5. Display the dollar amount that the player wins
6. Here is an example what the program should do:
Enter the dollar amount inserted into the slot machine: 100
Orange Apple Cherry
Sorry, you lost
Or
Enter the dollar amount inserted into the slot machine: 100
Orange Cherry Cherry
Congratulations, you won $100
Or
Enter the dollar amount inserted into the slot machine: 100
Orange Orange Orange
Congratulations, you won $300