Here you can find the source of parameterInput(int start, int end)
public static int parameterInput(int start, int end)
//package com.java2s; //License from project: Open Source License import java.util.InputMismatchException; import java.util.Scanner; public class Main { public static int parameterInput(int start, int end) { Scanner in = new Scanner(System.in); int choice = 0; boolean done = false; // Read a parameter value (int) from the keyboard while (!done) { try { choice = in.nextInt();/*from ww w. j av a2s . co m*/ } catch (InputMismatchException e) { in.nextLine(); System.out .println("Wrong type of input. Please try again."); continue; } if (choice > end || choice < start) { System.out .println("Wrong choice, there is no such option. Please try again."); } else { done = true; } } return choice; } }