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
-
18. A crackle test can show the presence of emulsified water in oil quite dramatically. When the amount of emulsified water becomes extreme, what are two ways to detect it visually?
-
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....
-
3. Nasly & Grace Boutique firm expects an EBIT of $74,500 every year forever. The company currently has no debt, and its cost of equity is 12 percent. The current tax rate is 23percent. A) Calculate...
-
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...
-
Can a critical value for the chi-square test be negative? Explain.
-
Frank Pepes Pizzeria Napoletana has opened one of the most recognizable pizzerias in the United States using word-ofmouth marketing. After returning from World War I, Frank Pepe initially began with...
-
Describe how an organizational culture and the use of performance criteria and standards affect the remaining components of a performance management system.
-
Stacey's Piano Rebuilding Company has been operating for one year (2019). At the start of 2020, its statement of earnings accounts had zero balances and the account balances on its statement of...
-
To foster the development of self-efficacy, parents and caretakers should: A. provide tasks which a child can easily achieve: B. structure tasks that are a challenge but with a high likelihood of...
-
5 E18-5 (Variable Consideration) Bai Biotech enters into a licensing agreement with Pang Pharmaceutical for a drug under development. Bai will receive a payment of 10,000,000 if the drug receives...
-
A circuit-switched network sets up a path between source and destination devices. The two devices use the same path, or circuit, throughout the conversation. This is the model the original analog...
-
DECISION SCIENCE DATA ANALYSIS: INTERIM REPORT via ORAL ASSESSMENT (Please refer to the guideline for your group project "Data Analysis Project Report") Assessment of this report is via ORAL...
-
(a) 35+12i The polar form is Give an exact answer.
-
Make up an outline for French cultural rules and gift giving for a presentation, write it in english. It must be Use a 12-pt font size. Double-spacing. . Write your outline using a writing style that...
-
Differentiate f(x) = ax5-4ax with respect to x. Assume that a is a constant.
-
Apply project management tools and a project management outline type of your choice to structure and plan the project by defining, planning, and controlling. Project Topic: "How Verizon Wireless can...
-
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...
-
Optimistic Oil Company incurred the following costs during the years 2016 and 2017: 2016 a. Contracted and paid $50,000 for G&G surveys during the year. b. Leased acreage in four areas as follows: 1)...
-
Record the following transactions: a. Landslide Energy incurred costs of $30,000 in preparing a drillsite. b. The contractor was paid $400,000 on a day-rate contract (all intangible). c. Equipment...
-
During 2015, ONeal Corporation incurred the following costs in connection with the Batch lease: a. Acquired the 800 acre Batch lease at a lease bonus of $70 per acre and other acquisition costs of...
Study smarter with the SolutionInn App