public static int getNumber(Scanner scanner, String message) {
        int number = 0;
        System.out.println(message);
        while (!scanner.hasNextInt()) {
            System.out.println("Error: incorrect data.\n" + message);
            scanner.next();
        }
        number = scanner.nextInt();
        return number;
    }