Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In Java, is there a way to pass the results of what I get in this method (5 unique random numbers and a random powerball)
In Java, is there a way to pass the results of what I get in this method (5 unique random numbers and a random powerball) to a separate array method which stores the result and checks for duplicates?
public static void lottopicks(int[]numpassed) { Scanner read = new Scanner(System.in); Random rand = new Random(); int num; int min = 1; int max; int num1; int min1=1; int max1=40; { while (true) { System.out.println("What is the upper range of values you want to use for Random numbers): " + "valid value is between 23 and 100 (e.g, enter 54 to generate numbers between 1 and 54)"); max = read.nextInt(); if(max >= 23 && max <= 100) { break; } System.out.println("Please enter a valid range. "); } System.out.println("The Easy Pick Randomly Generated Numbers Are:"); for (int i = 0; i <= 4; i++) { num = rand.nextInt((max + 1) - min) + min; System.out.print(num + " "); numpassed[i]=num; } for (int j=0; j<=0; j++) { num1 = rand.nextInt((max1 + 1) - min1) + min1; System.out.print("Powerball is " + num1); } } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started