PART 2 Problem #2: [35 pts] Write a java program that helps the Lebanese scout to...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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
Expert Answer:
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these programming questions
-
Predictive text entry systems are familiar on touch screens and mobile phones. This question asks you to consider how the same principles might be used in a programming editor for creating Java code....
-
Draw a graph showing the marginal revenue (MR) and marginal cost (MC) of increasing the tax rate (t) in the Peltzman model of regulation represented by equation (19.1). Place the tax rate on the...
-
The comparative, unclassified statement of financial position for Summerville Ltd. shows the following balances at December 31: Additional information for 2018: 1. Net income was $89,000. 2. A gain...
-
Bentley Hamilton throws the business section of The New York Times onto the conference room table and watches as his associates jolt upright in their overstuffed chairs. Mr. Hamilton wants to make a...
-
In 2016, a hacker tricked a Lamps Plus employee into disclosing the tax information of approximately 1,300 other employees, resulting in the filing of a fraudulent income tax return of Lamps Plus...
-
Paul Fenster owns and manages a chili- dog and soft-drink stand near the Kean U. campus. While Paul can service 30 customers per hour on the average (m), he gets only 20 customers per hour (l)....
-
An object moved on the xaxis from point A to point B, turned around and moved to point C in 2 seconds. Assume direction towards the right as the positive direction. The coordinates of A, B, and C are...
-
Hooyay is a low cost manufacturer of smartphones in Myanmar. They recently listed in 2017 on the Singapore Exchange and did not issue any dividends for 2017 and have no plans to for 2018. They do...
-
What are the origins of the common law? Name one or more Common Law principles that exist in our law today and explain them ?
-
In 2019, Cathy Cummings, single, 66 years of age, and legally blind, had wages and net rental income (after depreciation) of $30,000 and received $500 in interest income. She had $17,000 of allowable...
-
During 2019, Mary Maloney received a gift of property from her aunt. At the time of the gift, the property had a fair market value of $165,000, the taxable gift was $150,000, and the adjusted basis...
-
Explain the difference between the taxpayer- use test and the functional-use test, and give an example as to when each applies.
-
Kenneth King inherited 100 shares of Corporation ABC stock from his father, who died on March 4, 2019. His father paid $17 per share for the stock on May 3, 1999. The fair market value of the stock...
-
Milton and Maxine Miller purchased a home in New York City for $350,000 on October 1, 2018. Milton obtained a job in Richmond, Virginia, and on December 1, 2019, the Millers sold their home in New...
-
Assume a famer has an accounting period running from January 1 to December 31. Use the following information obtained for the past calendar year accounting period to complete an income statement and...
-
Bobbie Singh provides writing services for small businesses. He blogs for companies that need professionally written content. His business records at November 15, 2023, are shown below: During the...
-
Write a program that asks the user to enter the size of a triangle (an integer from 1 to 50). Display the triangle by writing lines of asterisks. The first line will have one asterisk, the next two,...
-
Repeat the previous exercise, but change next to nextLine in the statement that assigns a value to b. Previous exercise What does the Java code Scanner keyboard = new Scanner(System.in);...
-
It is important to consider the effect of thermal expansion when building a structure that must withstand changes in temperature. For example, a metal beam will expand in hot temperatures. The...
-
What are the features of a legal risk management plan?
-
What are residual powers? Concurrent powers?
-
Why have business enterprises adopted codes of conduct?
Study smarter with the SolutionInn App