Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribed

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:

image text in transcribed

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

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

Learning PostgreSQL

Authors: Salahaldin Juba, Achim Vannahme, Andrey Volkov

1st Edition

178398919X, 9781783989195

More Books

Students also viewed these Databases questions

Question

What is an industry?

Answered: 1 week ago

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago