If I understand you correctly, you want the program to ask the user to re-enter the correct input after the failure. In this case, you can do something like:
boolean inputOk = false;
while (!inputOk) {
System.out.print("Define width: ");
try {
width = scanner.nextDouble();
inputOk = true;
} catch (InputMismatchException e) {
System.err.println("That not a number!");
scanner.nextLine();
}
}
: InputMismatchException. nextXxx , , .