Question: Write a program that will simulate a lottery game based of lotto 6/49 in Java Create 2 classes: Lotto649 and Testlotto 1. Generate 6 non

Write a program that will simulate a lottery game based of lotto 6/49 in Java

Create 2 classes: Lotto649 and Testlotto

1. Generate 6 non repetitive numbers between 1 and 49 (integers) to be the winning numbers.

2. A user inputs his 6 non repetitive numbers between 6 and 49.

3. Both combination are being sorted from lowest numbers to highest. Compare both combination. If there is 2 similar numbers, the user wins 10$, if 3 similar number, the user wins 20$, etc. If the user gets the 6 numbers right, the user wins 1 millions $

4. The users has 3 tries each round

5. The Lotto649 class must contain:

public boolean start() //starts the game with 3 tries, generate a winning ticket, and validate the input of the user

public void generateWinningCombination() //generate 6 non-repetitive integers between 1-49

public boolean validateUserCombination() //verifies that the user input has 6 non-repetitive numbers from 1-49

public String compareCombination() //sort the winning combination and user combination in ascending order and return how many numbers found

public boolean win() //verifies that the user has found 2 or more winning numbers

public int calculateWins() //calculate the earnings in dollars according to the amount of numbers found

2 numbers: 10$

3 numbers: 20$

4 numbers: 100$

5 numbers: 5000$

6 numbers: 1 millions $

public String display() // displays the result of the game

6. The game is being played in the class TestLotto

Example of a game

1st try :

User input : [6, 7, 12, 24, 33, 42]

Lottery result

Your combination : [6, 7, 12, 24, 33, 42]

Lottery draw : [11, 18, 22, 25, 42, 48]

Similar numbers : 0

You lost. Better luck next time

2nd try :

User input : [6, 7, 12, 24, 33, 45]

Lottery result

Your combination : [6, 7, 12, 24, 33, 45]

Lottery draw : [12, 27, 28, 30, 31, 45]

Similar numbers : 2

Congratulations! You won 10$.

3rd try :

User input : [6, 6, 10, 43, 32, 9]

Invalid combination.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!