Question: In this assignment you will create a console (standalone) application. This program will allow you to select numbers for the Lucky For Life Lottery game.

In this assignment you will create a console (standalone) application. This program will allow you to select numbers for the "Lucky For Life" Lottery game. For the first 5 numbers you will be requested to enter a number that is greater than zero and less than 49 since the first 5 numbers on the "Lucky For Life" lottery must be between 1- 48. However, theres a catch! Each of these five numbers must be different.

This is what I have done so far, it's right:

LuckyForLife.java

import java.util.*; class LuckyForLife { int[] winningNumbers = new int[5]; int powerball; //Print the data to Console public void WriteOutput() { System.out.println("Your powerball numbers are "); for (int i = 0; i

//Taking Input from Console public void ReadInput() { Scanner sc = new Scanner(System.in); int j = 1; while (true) { System.out.print("Please enter number " + j + " which should be greater than 0 and less than 49: "); int n = sc.nextInt(); //if number is invalid if (n=49) { if (n = 18) { if(p_ball

---------------------------------------------------------------------------------------

LuckyForLifeDemo.java

public class LuckyForLifeDemo {

public static void main(String[] args) { // TODO Auto-generated method stub LuckyForLife powerball = new LuckyForLife(); powerball.ReadInput(); powerball.WriteOutput();

}

}

-------------------------------------------------------------------------------------------

The above displays as:

In this assignment you will create a console (standalone) application. This program

The thing I need help with is this part:

Create an array for the first five winning numbers. Make sure you set a maximum allowed value for these first five winning numbers. For the winning lucky ball create an integer that is generated within the allowed range of values. Hint on finding the winning numbers and making sure the first five numbers are different:

-You need to use some kind of random number generator

-To compare a number with the other numbers in the array you want to check all but the number that has the index number of the for loop variable. For example: First create a for loop with a starting point of zero and an ending point of less than the length of the array, Within the loop create the random number for the array element with an index number of the for loop variable, Create an inner for loop with the same starting and ending point of the outer for loop. Remember that the name of the variable must be different than in the outer loop, Within this inner for loop you need an if statement that:

if the array element with an index number of the variable of the outer loop is equal to the array element within an index number of the element with an index number of the inner loop variable AND the variable of the inner loop DOES NOT equal the value of the outer loop variable, then regenerate the random number for array element as done at the beginning of the outer loop. An example of the if statement argument might be: if(winningNumbers[i] == winningNumbers[j] && j != i) Where i is the name of the variable in the outer loop and j is the name of the variable in the inner for loop.

It needs to look like this:

will allow you to select numbers for the "Lucky For Life" Lottery

Please please please help me, I'm so desperate to figure this last part out.

Please enter number 1 which should be greater than 0 and less than 49 5 Please enter number 2 which should be greater than 0 and less than 49 4 Please enter number 3 which should be greater than 0 and less than 49 3 Please enter number 4 which should be greater than 0 and less than 49 2 Please enter number 5 which should be greater than 0 and less than 49 1 Please enter a number that is greater than 0 and less than 18 for your lucky Powerball numberl 18 The Powerball must be less than 18 Please enter a number that is greater than 0 and less than 18 for your lucky Powerball number 17 Your power ball numbers are and the Powerball number is 17

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!