https://www.txlottery.org/export/sites/lottery/Games/Pick_3/
Write a Java Program to Play your version of the Texas Pick 3 Lottery. You will need to include the provided code given below in your program.
We will use 1 number as 000-999 instead of 3 separate values.
- In the main() method, declare an int named myPick3choice.
- Create a prompt for myPick3 as “Enter your Pick 3 choice:0-999”.
- Create a method named playPick3 that has an int parameter named myPick3.
- In the playPick3 method, do the following:
- Create an int variable called playCounter and initialize it to 0.
- Create an int variable called myPick3Result.
- If myPick3Result matches the variable myPick3, then display the result of playcounter as “PlayCounter = ….” and exit the loop.
- If myPick3Resultdoes not match, increment the variable playCounter and continue the loop.
Create a loop that calls the method officialPlayPick3 (Provided below) and store the result in myPick3Result.
5 points Extra Credit.
Create a loop in the main method to allow you to play as often as you wish.
Enter your Pick 3 choice 0-999: 554
PlayCounter = 1343 ( This result will vary )
Include the code below in your program. The code also requires the following import line:
import java.util.concurrent.ThreadLocalRandom;
/**
* officialPlayPick3()
* Returns a random number 0-999
* @return int
*/
public static int officialPlayPick3() {
final int min = 0;
final int max = 999;
return ThreadLocalRandom.current().nextInt(min, max + 1);
}