Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a push your luck program where a user can continually get a random number between 1 and 11 until she decides to quit or
Write a push your luck program where a user can continually get a random number between 1 and 11 until she decides to quit or the numbers sum exceeds 21. In Java.
Write a "push your luck" program where a user can continually get a random number between 1 and 11 until she decides to quit or the numbers' sum exceeds 21. 1. Create a class called Lab7 2. To break up this problem, first write code that allows a user to enter a letter and then the program prints out a random number from 1 to 11 each time the user enters a letter. The program should continue reading in letters and printing out random numbers until the user types the letter q at which point the program should stop. 3. When you have this working, modify your code to track the sum of all the random numbers. The program should stop if the user enters the letter q or if the sum is greater than 21. 4. Before ending, the program should print out "You win!" if the sum is between 19 and 21 (inclusive), "So close!" if the sum is less than 19, or "You bust!" if the sum is over 21. Sample input/output Example 1 Example 2 Push your luck! Push your luck! Random number: 11 Randon number: 5 Updated sum: 11 Updated sum: 5 Random number: 7 Randon number: 2 Updated sum: 7 Updated sum: 18 Random number: 3 Randon number: S Updated sum: 12 Updated sum: 21 You win! Thanks for playing! Final sum: 21 Randon number: 8 Updated sum: 26e Random number: 6 Updated sum: 26 You bust! Thanks for playing! Final sum:26 Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started