I have simple java program that accepts 3 user inputs of type integer, double and string. I would like to know the best/most efficient way to perform error handling on all of these inputs in order to keep the program running, inform the user they have entered an incorrect input and ask them the question again . Any help would be greatly appreciated.
Here is my code
Scanner scan = new Scanner(System.in);
int inputInt;
double inputDbl;
String inputString;
System.out.print("Please enter a whole number: ");
inputInt = scan.nextInt();
System.out.print("Please enter a decimal number: ");
inputDbl = scan.nextDouble();
System.out.print("Please enter a string: ");
inputString = scan.next().toLowerCase();
hasNextInt()andhasNextDouble()methods of scanner before callingnextInt(),nextDouble().