1boolean badNumber;
2Scanner sc = new Scanner(System.in);
3do{
4 System.out.print("Please print your number: ");
5 try{
6 int i = sc.nextInt();
7 System.out.println("Your Number is: " + i);
8 badNumber = false;
9 }
10 catch(Exception e){
11 System.out.println("Bad number");
12 sc.next();
13 badNumber = true
14 }
15}while(badNumber);
16