






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







Computer Programming I Instructor: Greg Shaw COP 2210
( Decision-Making )
A typical slot machine consists of 3 rotating disks. If certain combinations appear when the disks stop spinning, the player wins varying amounts of money. Suppose that each disk contains the integers from 0 through 9. Write a program where the user enters the values for the 3 disks and the amount wagered, and an appropriate message is printed as shown in the following table.
All 3 Numbers The Same 100 to 1 Any 2 Numbers The Same 4 to 1 3 Consecutive Numbers 60 to 1 Anything Else
(Player Loses)
such as these would win: 1 2 3 3 2 1 4 5 6 6 5 4 etc. ...but not these:
1 3 2 (consecutive but not in order) 9 0 1 (no “wrap around”)
A zip file containing both Java classes and the 5 sets of output
order would be only 20 to 1 (not 60 to 1) Slot Machine Assignment (6) (Copy and paste when necessary) SlotMachine.java /* File: SlotMachine.java
return same3Slots ; } /**
inclusive
playing System.out.println(Game.getSlotsAndWager()) ; // This method enforces rules of the game and prints the receipt System.out.println(Game.playSlots()) ; } } // Input Data: // // A. 7 7 7, $ // B. 7 3 7, $ // C. 0 1 2, $ // D. 9 8 7, $ // E. 5 3 4, $ // F. 8 9 10, $ // G. 5 6 0, $ /* Output for A. @ Name (§U0#) Numbers Entered: 7, 7, & 7 Amount wagered: $ Congratulations! You have won the jackpot! You won: $100! Also, reclaim your wager of: $ BUILD SUCCESSFUL (total time: 0 seconds) / / Output for B. @ Name (§U0#) Numbers Entered: 7, 3, & 7 Amount wagered: $ Congratulations! You have won a prize! You won: $4! Also, reclaim your wager of: $ BUILD SUCCESSFUL (total time: 0 seconds) / / Output for C. @ Name (§U0#) Numbers Entered: 0, 1, & 2 Amount wagered: $ Congratulations! You have won a prize! You won: $20! Also, reclaim your wager of: $ Remember that consecutive numbers can be in any order, this is why I changed the ratio from 60 : 1 to 20 : 1 as instructed. BUILD SUCCESSFUL (total time: 0 seconds) / / Output for D.