Introduction to java: Gambling Objectives: •Performing decisions using if and switch statements. •Using relational and logical operators •Working with...

70.2K

Verified Solution

Question

Programming

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

Answer & Explanation Solved by verified expert
4.0 Ratings (539 Votes)
Short SummaryImplemented the gambling program and shown you the sampleoutputProvided inline comments appropriately Please upvote the answer and appreciate ourtime Source Codeimport javautilScannerpublic class Gambling Generates random integer return random integer in range of 1 to 4 public static int getRandomInt int min 1 int max 4 return intMathrandom max min 1 min param    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students