Question: version 3: import java.util.Arrays; import java.util.Scanner; public class Lottery3 { public static boolean isvalid(int x){ if(x >= 1 && x Duplicate number. Try again.); }

version 3: import java.util.Arrays; import java.util.Scanner; public class Lottery3 { public staticversion 3:

import java.util.Arrays; import java.util.Scanner; public class Lottery3 { public static boolean isvalid(int x){ if(x >= 1 && x Duplicate number. Try again."); } }else{ /** * If isvalid() function returns false then we print * following message. */ System.out.println(" ERROR==> Please select from 1-54."); } }/*while loop ends here*/ /** * Now that we have unique numbers in array[], * we need to sort the array. * We can sort array using Arrays.sort() function as follows. */ Arrays.sort(array); /** * Finally we print the array as required. */ System.out.println(" Playing the following 6 numbers"); i=0; while(i

java programming

For version 4, we will simulate the actually lottery drawing. In your main method, after you have six valid lottery numbers, add additional code which creates another array to contain the winning values called "winners". Write a loop that selects a random value in the range of 1-54 and put those values in the six locations in the winners array. You must use the isUnique method you created in version 3 to make sure the random numbers drawn are all unique. Name the class Lottery4 Continue to use the main method to manage the loops and main flow control. . . Add another integer array named "winners" which will contain the six winning lottery numbers. .Add code to generate six unique randomly selected numbers in the range of 1-54 and store them in the winners array. Sort the array after all numbers are selected using Arrays.sort. Print out the six "winning" numbers that were randomly drawn. SAMPLE OUTPUT: >java Lottery4 Enter a number from 1-54 (pick #1): 1 Enter a number from 1-54 (pick #2): 3 Enter a number from 1-54 (pick #3): 5 Enter a number from 1-54 (pick #4): 7 Enter a number from 1-54 (pick #5): 9 Enter a number from 1-54 (pick #6): 2 Playing the following six numbers: 123579 The winning numbers are: 3 13 14 23 28 53

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!