Build a simple lottery program that asks the user to input six numbers, prints those numbers, spins 6 random lottery numbers, and compares them to the user's chosen number. The prize is “1000” if the selected lottery numbers match at least 3 of the 6 created numbers. The prize is “2000” if it matches 4 numbers. The prize is “4000” if it matches 5 numbers. The prize is "8000" if it matches all of the numbers. The prize is "0" if it matches ≤2 winning numbers.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter2: Using Data
Section: Chapter Questions
Problem 3GZ
icon
Related questions
Question

 

Build a simple lottery program that asks the user to input six numbers, prints those numbers, spins 6 random lottery numbers, and compares them to the user's chosen number. The prize is “1000” if the selected lottery numbers match at least 3 of the 6 created numbers. The prize is “2000” if it matches 4 numbers. The prize is “4000” if it matches 5 numbers. The prize is "8000" if it matches all of the numbers. The prize is "0" if it matches ≤2 winning numbers.
Make 2 classes that meet the following criteria:
1. The first class asks input from the user and then shows the result. The result(int num) method must determine which reward is appropriate for the user and show the outcome.
2. The lottery function must be included in the second class. This should include the spin(), setwinninglottery(), and compare methods (int num[ ], int lot[]).
3. The spin() method creates 6 random lottery winning numbers ranging from 1 to 45.
4. Repeated values are not acceptable. It's important to note that this method only returns one lottery number each call.
6. Sets the six lottery winning number from a spin with the setwinninglottery() method ().
7. To compare the user's six selected numbers with the six winning lottery numbers, a compare(int num[ ]) method must be defined. This determines the quantity of numbers that matches then returns it to the main class.
Sample Output
Choose six numbers: 6 9 44 23 31 18
Initiating Winning Numbers…
Winning Lottery numbers: 31 1 9 45 43 18
Number of Matches: 3
Your reward is: USD 1000

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr