Question: In Java, same numbers are generated for each instance of variable called. Gives me same number for each time I call either fantasy5Number or lottoNumber

In Java, same numbers are generated for each instance of variable called. Gives me same number for each time I call either fantasy5Number or lottoNumber

//******************************************************************************* package assignment_1_lotto; import java.util.Random; import javax.swing.JOptionPane;

/** * * @author hades */ public class Assignment_1_Lotto {

/** * @param args the command line arguments */ public static void main(String[] args) { // This program will randomly generate a series of winning numbers (hopefully) //for both the Lotto and Fantasy 5 games that mom loves to play. Random randomNumber = new Random(); // for either lottery game, this //will generate a single random # int fantasy5Number = 1 + randomNumber.nextInt(36); //Fantasy 5 number int lottoNumber = 1 + randomNumber.nextInt(53); // Lotto number JOptionPane.showMessageDialog(null, "Here are your numbers!! " + "Fantasy 5 : " + fantasy5Number + " " + fantasy5Number + " " + fantasy5Number + " " + fantasy5Number + " " + fantasy5Number + " " + "Lotto : " + lottoNumber + " " + lottoNumber + " " + lottoNumber + " " + lottoNumber + " " + lottoNumber + " " + lottoNumber + " " + "Let's " + "hope you finally win for both our sakes! :D ");

//the end. } }

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!