Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have this java program but I need to develop this to match instruction given: Simulate the real lottery MEGA MILLIONS and create a good

I have this java program but I need to develop this to match instruction given:

Simulate the real lottery MEGA MILLIONS and create a good GUI. The rule of the game is (from Internet): The Lottery game in which the ticket purchaser selects, or has the computer randomly assign five (5) different numbers from Field 1 which includes a range of consecutive numbers from one (1) to fifty-six (56) and one (1) number from Field 2 which includes a range of consecutive numbers from one (1) to forty-six (46), shall be called MEGA MILLIONS". For example, the winning numbers from Field 1 may be {03, 05, 10, 20, 43} and from Field 2 {05}. As you can see the number from Field 2 may be the same as one of the numbers of Field 1. You have different ways to develop your algorithm and code. One of the ways is to use ArrayList. You are free to select some other way. Please give UML diagrams for all classes.

import java.util.*; import java.lang.*; import java.io.*; class lottery { public static void main(String[] args) { int[] lottery = new int[5]; int randomNum; for (int i = 0; i < 5; i++) { randomNum = (int) (Math.random() * 56); for (int x = 0; x < i; x++) { if (lottery[x] == randomNum) { randomNum = (int) (Math.random() * 56); x = -1; } } lottery[i] = randomNum; } for (int i = 0; i < lottery.length; i++) System.out.print(lottery[i] + " "); } 

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Database Systems

Authors: Carlo Zaniolo, Stefano Ceri, Christos Faloutsos, Richard T. Snodgrass, V.S. Subrahmanian, Roberto Zicari

1st Edition

155860443X, 978-1558604438

More Books

Students also viewed these Databases questions

Question

4. What action should Cherita Howard take and why?

Answered: 1 week ago