import java.util.Scanner;
import java.util.Random;
import static java.lang.System.out;
public class lotto {
public static void main (String[] args) {
Scanner myScanner = new Scanner(System.in);
Random myRandom = new Random();
int RandomNumber = 0, UserNumber = 0, times = 1, done = 0, givennumber=0, TotalNumbers = 0;
System.out.println ("As we know if you could only pick a number");
System.out.println (" out of 1 million your chances are 1 in 1 million:");
System.out.println ("today I am going to prove this...I hope");
System.out.println ();
do{
System.out.print("Pick a maximum number (larger numbers take longer): ");
System.out.println ("(must be greater than 2)");
TotalNumbers = myScanner.nextInt();
}while(TotalNumbers < 2);
givennumber = (myRandom.nextInt(TotalNumbers) + 1);
System.out.println("Pick a number between 1 and " + Integer.toString(TotalNumbers) + " (for example " + Integer.toString(givennumber) + "): ");
System.out.println("Bad responses will be forced to reenter:");
do{
UserNumber = myScanner.nextInt();
if (UserNumber > TotalNumbers) {
System.out.println ("Must be less than " + TotalNumbers + " Please type again:");
}
else if (UserNumber < 1){
System.out.println ("must be greater than 0 Please type again:" );
}
}while(UserNumber < 1 || UserNumber > TotalNumbers);
System.out.println ();
System.out.println ();
do{
RandomNumber = (myRandom.nextInt(TotalNumbers) + 1);
System.out.println (RandomNumber);
times += 1;
}while(RandomNumber != UserNumber);
System.out.println ();
System.out.print ("it took ");
System.out.print (times);
System.out.println (" times untill your number came up, with: " +(TotalNumbers) + " likly numbers that could pop up (this is not fake)");
System.out.println ("can you belive it...want to try again");
System.out.println ("...for me it took 1765826 times picking total number = 1 million");
}
}
//}
hopfully it has no bugs and it is alright