protected double readDouble(double min, double max) {
        double result = min - 1;
        while (result < min || result > max) {
            try {
                result = scanner.nextDouble();
                if (result > max || result < min) {
                    System.out.println("Wrong input, try again.");
                }
            } catch (InputMismatchException ex) {
                scanner.nextLine();
                System.out.println("Wrong input, try again.");
                result = min - 1;
            }
        }
        return result;
    }