Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PART 2 Problem #2: [35 pts] Write a java program that helps the Lebanese scout to create an online tombola (lottery). Your program should
PART 2 Problem #2: [35 pts] Write a java program that helps the Lebanese scout to create an online tombola (lottery). Your program should generate a random number between 10 and 99 using Math.random(). It should then ask the user to enter 2 numbers each of 1 digit only (0 to 9) and compares these digits with the random number. If the 2 digits match the same placed digits in the number, your program outputs "Congratulations, You win the tombola" and the random number. The user is allowed to repeat his guess for 10 times maximum. For example, if the program generates 73 and the user enters 7 and 3, then the user wins. If the user enters 3 and 7, the user loses the round. Sample Run 1: Enter a 2 digits: 1 6 Wrong, 9 tries left Enter 2 digits: 3 5 Wrong, 8 tries left Enter 2 digits: 1 6 Wrong, 7 tries left Enter 2 digits: 9 1 Congratulations, You win the tombola, the random number is 91 ! Sample Run 2: Enter 2 digits: 19 Wrong, 9 tries left Enter 2 digits: 1 2 Wrong, 8 tries left Enter 2 digits: 26 Wrong, 7 tries left Enter 2 digits: 1 6 Wrong, 6 tries left Enter 2 digits: 19 Wrong, 5 tries left Enter 2 digits: 1 2 Wrong, 4 tries left Page Q + Sample Run 1: Enter a 2 digits: 1 6 Wrong, 9 tries left Enter 2 digits: 3 5 Wrong, 8 tries left Enter 2 digits: 1 6 Wrong, 7 tries left Enter 2 digits: 9 1 Congratulations, You win the tombola, the random number is 91 ! Sample Run 2: Enter 2 digits: 1 9 Wrong, 9 tries left. Enter 2 digits: 1 2 Wrong, 8 tries left Enter 2 digits: 26 Wrong, 7 tries left Enter 2 digits: 1 6 Wrong, 6 tries left Enter 2 digits: 19 Wrong, 5 tries left Enter 2 digits: 1 2 Wrong, 4 tries left Enter 2 digits: 1 9 Wrong, 3 tries left Enter 2 digits: 1 3 Wrong, 2 tries left Enter 2 digits: 90 Wrong, 1 tries left Enter 2 digits: 9 8 Wrong, 0 tries left. You lost, the random number is 45 ! Page 4 / 4 - Q + Page 4 of 4
Step by Step Solution
★★★★★
3.40 Rating (150 Votes )
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