// required variables int choice = 0; int choiceTwo = 0; System.out.print("First professor: "); String entryOne = jmhUtilities.ReadLine(); try { choice = Integer.parseInt(entryOne); } catch(NumberFormatException nfe) { System.out.println("\n Invalid input of non-numeric type." + "\n Enter an integer between 1 and " + size + " next time.\n"); return true; } catch (IndexOutOfBoundsException ioobe) { System.out.println("\n Input entered is larger than list size." + "\n Enter an integer between 1 and " + size + " next time.]n"); return true; } System.out.print("Second choice(range's end): "); String entryTwo = jmhUtilities.ReadLine(); try { choiceTwo = Integer.parseInt(entryTwo); } catch (NumberFormatException nfe) { System.out.println("\n Invalid input of non-numeric type." + "\n Enter an integer between 1 and " + size + " next time.\n"); return true; } catch (IndexOutOfBoundsException ioobe) { System.out.println("\n Input entered is larger than list size." + "\n Enter an integer between 1 and " + size + " next time.]n"); return true; } // quit the operation if user desires to do so if ( choice < 1 || choiceTwo > size ) { System.out.println("\n Quitting - returning to main menu.\n"); return true; // take the appropriate action as requested } else if ( (choice >= 1 && choice < size) && choiceTwo > 1 ) { // erase professors at choice - 1 location for (int i = choice; i < choiceTwo; i++) { profs.remove(i); // erase the professor } // notify user of success System.out.println("\n Elements succesfully deleted. 'P' to print.\n"); // invalid input handling } else { System.out.println("\n Invalid input. Please try again." + "\n Next time enter an integer between 1 and " + size + "."); } }