1Scanner sc = new Scanner(System.in);
2int number;
3do {
4 System.out.println("Please enter a positive number!");
5 while (!sc.hasNextInt()) {
6 System.out.println("That's not a number!");
7 sc.next(); // this is important!
8 }
9 number = sc.nextInt();
10} while (number <= 0);
11System.out.println("Thank you! Got " + number);