Example 1 (using if/else statements) Problem: The program should check if input is integer and return error if input is greater than 15. Scanner in=new Scanner(System in); if (in.hasNextInt()) { int input=in.nextInt(); if(input==1) {...} else if(input==2) {...} else if(input==3) {..} else {System.out.println("error")} } else { System.out.println("not an Integer: " + in.next()); } Example 2 (The same problem but with use of switch): Scanner in=new Scanner(System in); if (in.hasNextInt()) { int input=in.nextInt(); switch(input) { case 1: {...}; break; case 2: {...}; break; ... default {error} } } else { System.out.println("not an Integer: " + in.next()); } Example 3 (Another implementation of input): Scanner in=new Scanner(System in); String input = in.next(); if(input.matches("(0)*+[0-9]{1,10}")) { int IntInput=Integer.parseInt(input); ... } else System.out.println("error"); Example 4 (Using Arrays): Scanner in=new Scanner(System in); String input = in.next(); char[]a=input.toCharArray(); for(int i=0; i