Jumping in the Mega Millions fever, your lab is to write a program that simulates the Mega Millions lottery draw. Your program must have an array of five integers named winningNumbers, with a randomly generated number in the range of 0 through 9 for each element in the array. Your program should ask the user to enter five numbers and should store them in a second integer array named player. The program must compare the corresponding elements in the two arrays and count how many numbers match. For example, the following shows the winningNumbers array and the Player array with sample numbers stored in each. There are two matching elements, elements 2 and 4. Once the user has entered a set of numbers, the program should display the winning numbers and the player's numbers and tell how many numbers matched. Here is an example of the possible output from your code: /* SAMPLE RESULTS RUN 1 Submit the five numbers of your lottery number, separated by blanks: 93441 Winning number: 30766 Your number : 93441 You have 0 matching digit(s). SAMPLE RESULTS RUN 2 Enter the five numbers of your lottery number, separated by blanks: 55417 Winning number: 46419 Your number : 55417 You have 2 matching numbers.∗/

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter8: Arrays
Section: Chapter Questions
Problem 9PE
icon
Related questions
Question

Jumping in the Mega Millions fever, your lab is to write a program that simulates the Mega Millions lottery draw. Your program must have an array of five integers named winningNumbers, with a randomly generated number in the range of 0 through 9 for each element in the array. Your program should ask the user to enter five numbers and should store them in a second integer array named player. The program must compare the corresponding elements in the two arrays and count how many numbers match. For example, the following shows the winningNumbers array and the Player array with sample numbers stored in each. There are two matching elements, elements 2 and 4. Once the user has entered a set of numbers, the program should display the winning numbers and the player's numbers and tell how many numbers matched. Here is an example of the possible output from your code: /* SAMPLE RESULTS RUN 1 Submit the five numbers of your lottery number, separated by blanks: 93441 Winning number: 30766 Your number : 93441 You have 0 matching digit(s). SAMPLE RESULTS RUN 2 Enter the five numbers of your lottery number, separated by blanks: 55417 Winning number: 46419 Your number : 55417 You have 2 matching numbers.∗/ 

Please give proper explanation and typed answer only.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
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++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage