109,596 views
30 votes
30 votes
This criterion is linked to a Learning OutcomeCreate checkDuplicates method that receives an array of ints, and an int as parameters. It will return true if the int is found in the array, and false if the int is NOT found in the array. Call the checkDuplicates method from both the MegaMillionsLottery constructor, and the getUserPicks() method.

User Orquesta
by
2.4k points

1 Answer

6 votes
6 votes

Answer:

Step-by-step explanation:

The MegaMillions Lottery class was not provided and neither was the getUserPicks() method. Since they were not found online either, I have created the checkDuplicates method so that it works standalone. Therefore, you can simply call the method from wherever you need by pasting the call line where it needs to be called. A test case has been created in the main method so that you can see the method in action. The output is seen in the attached image below.

public static boolean checkDuplicate(int[] myArr, int element) {

for (int x : myArr) {

if (x == element) {

return true;

}

}

return false;

}

This criterion is linked to a Learning OutcomeCreate checkDuplicates method that receives-example-1
User Jenessa
by
2.9k points