Revise Listing 3.8, Lottery.java, to generate a lottery of a twodigit number. The two digits in the
Question:
Revise Listing 3.8, Lottery.java, to generate a lottery of a twodigit number. The two digits in the number are distinct.?
Listing 3.8
Transcribed Image Text:
1 import java.util.Scanner; 2 3 public class Lottery { public static void main(String[] args) { 4 // Generate a lottery number 5 int lottery = (int)(Math.random() * 100); // Prompt the user to enter a guess Scanner input = new Scanner (System.in); System.out.print("Enter your lottery pick (two digits): "); int guess = input.nextInt(); 8 10 11 12 13 // Get digits from lottery int lotteryDigitl = lottery / 10; int lotteryDigit2 = lottery % 10; 14 15 16 17 18 // Get digits from guess int guessDigit1 = guess / 10; int guessDigit2 = guess % 10; 19 20 21 22 23 System.out.printIn("The lottery number is " + lottery); // Check the guess if (guess == 1ottery) System.out.print1n("Exact match: you win $10,000"); else if (guessDigit2 == lotteryDigitl && guessDigitl =- lotteryDigit2) System.out.println("Match all digits: you win $3,000"); else if (guessDigitl == lotteryDigitl || guessDigitl || guessDigit2 == lotteryDigitl || guessDigit2 System.out.println("Match one digit: you win $1,000"); 24 25 26 27 28 29 30 lotteryDigit2 31 32 lotteryDigit2) 33 else System.out.println("Sorry, no match"); 34 35 36 37 } Enter your lottery pick (two digits): 15 -Emter The lottery number is 15 Exact match: you win $10,000 Enter your lottery pick (two digits): 45 Jenter The lottery number is 54 Match all digits: you win $3,000 Enter your lottery pick: 23 - Enter The lottery number is 34 Match one digit: you win S1,000 Enter your lottery pick: 23 -Enter The lottery number is 14 Sorry: no match line# 11 14 15 18 19 33 variable lottery 34 guess 23 lotteryDigitl lotteryDigit2 4 guessDigitl guessDigit2 Output Match one digit: you win $1,000
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 77% (9 reviews)
Output 80 81 82 83 84 85 86 87 88 89 Program that finds lottery Compile Javac Lotteryj...View the full answer
Answered By
Kennedy Odhiambo
As a professional writer, I have been in the field for over 5 years having worked as a lecture in different tertiary institutions across the world. With this impeccable experience, I assure provision of a good and supporting environment for students to learn.
5.00+
2+ Reviews
10+ Question Solved
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Question Posted:
Students also viewed these Computer science questions
-
Revise Listing 3.8, Lottery.java, to generate a lottery of a threedigit number. The program prompts the user to enter a three-digit number and determines whether the user wins according to the...
-
Revise Listing 3.4, ComputeAndInterpretBMI.java, to let the user enter weight, feet, and inches. For example, if a person is 5 feet and 10 inches, you will enter 5 for feet and 10 for inches. Here is...
-
Revise Listing 30.10, ParallelMergeSort.java, to define a generic parallelMergeSort method as follows: Listing public static void parallelMergeSort(E[] list) 1 import...
-
Write a filter KamasutraCipher that takes two strings as command-line argument (the key strings), then reads strings (separated by whitespace) from standard input, substitutes for each letter as...
-
Why is f not a function from R to R if a) f (x) = 1/x? b) f (x) =x? c) f (x) = (x2 + 1)?
-
How would YOU explain the organisational climate of (i) your university; (ii) your faculty or department? What specific examples can you provide?
-
Quilts R Us (QRU) is considering investing in a new patterning attachment with the cash flow profile shown in the table below. QRU's MARR is 13.5 percent/year. a. What is the internal rate of return...
-
The following information is taken from the financial statements of Aruban Enterprises. The company elects to use the carryback provisions of the tax law. Instructions: 1. Given the information from...
-
An 88-year-old presents to a primary care office with their daughter for concerns of a skin ulceration on the lateral ankle with hair loss. This has been ongoing for months and has recently worsened....
-
of 31 Ashley Foods, Inc. has determined that any one five machines can be used in one phase of its chili canning operation. The costs of the machines are estimated below, and all machines are...
-
A positive integer is called a perfect number if it is equal to the sum of all of its positive divisors, excluding itself. For example, 6 is the first perfect number because 6 = 3 + 2 + 1. The next...
-
Suppose you put $10,000 into a CD with an annual percentage yield of 5.75%. After one month, the CD is worth? 10000 + 10000 * 5.75 / 1200 = 10047.92 After two months, the CD is worth? 10047.91 +...
-
A small airplane flying horizontally with a speed of 180 mi/hr at an altitude of 400 ft above a remote valley drops an emergency medical package at A. The package has a parachute which deploys at B...
-
Consider the subspace W = {(x, y, z) | x+2y-2=0} of the vector space R. Let P: R3 R denote the orthogonal projection of R onto W. (a) Write the formula for P(v) (the image under P of a general vector...
-
A 0.47F and a 0.71 F capacitor are connected in series to a 12 V battery.
-
what are the common barriers of communication and how to overcome them? Explain
-
what is the significance of tailoring the types of informationrequired for each of the three project levels and how does it influence decisionmaking and overall project success?
-
what is the term for a behavior that serves the same functional outcome as the challenging behavior?
-
Examine the working paper for Vandervoort Company Ltd, shown in Figure 6.10. a. List the deficiencies in the working paper. b. For each deficiency, state how the audit schedule could be improved. c....
-
Consider the advantages and disadvantages of extending property rights so that everyone would have the right to prevent people imposing any costs on them whatsoever (or charging them to do so).
-
Which of the following expressions correctly returns an integer that represents the month of a LocalDate object named hireDate? a. getMonth(hireDate) b. getMonthValue(hireDate) c....
-
Create a class named FormLetterWriter that includes two overloaded methods named displaySalutation(). The first method takes one String parameter that represents a customers last name, and it...
-
Create a class named Billing that includes three overloaded computeBill() methods for a photo book store. When computeBill() receives a single parameter, it represents the price of one photo book...
-
Panjandrum Industries, a manufacturer of industrial piping, is evaluating whether it should expand into the sale of plastic fittings for home garden sprinkler systems. It has made the above estimates...
-
How might the application of cognitive appraisal theory inform motivational interventions aimed at reframing individuals' perceptions of obstacles and setbacks as opportunities for growth and...
-
A 5-year bond that pays interest semiannually has a 7% coupon and an 8% quoted yield to maturity. Annual interest rates increase 50 basis points. What is the predicted change in the bond price after...
Study smarter with the SolutionInn App