title: How to keep my code running after an exception is caught (Java)
body: <p>I'm trying to write code for a class project that can handle all exceptions and invalid entries from the user. </p>
  
  <pre><code>import java.util.Scanner;
  
  public class Paint1 {
  
  public static void main(String[] args) {
      Scanner scnr = new Scanner(System.in);
      double wallHeight = 0.0;
      double wallWidth = 0.0;
      double wallArea = 0.0;
      double gallonsPaintNeeded = 0.0;
  
      final double squareFeetPerGallons = 350.0;
  
      // Implement a do-while loop to ensure input is valid
      // Prompt user to input wall's height
      try {
          //System.out.println("Enter wall height (feet): ");
          do {//wallHeight = scnr.nextDouble();
              System.out.println("Enter wall height (feet): ");
              wallHeight = scnr.nextDouble();
              if (wallHeight &lt;= 0) {
                  System.out.println("Invalid height");
              }
          } while (wallHeight &lt;= 0);
      } catch (Exception excpt) {
          System.out.println("Invalid height");
          wallHeight = scnr.nextDouble();
      }
  
      // Implement a do-while loop to ensure input is valid
      // Prompt user to input wall's width
      do {
          System.out.println("Enter wall width (feet): ");
          wallWidth = scnr.nextDouble();
          if (wallWidth &lt;= 0) {
              System.out.println("Invalid Width");
          }
      } while (wallWidth &lt;= 0);
  
  
      // Calculate and output wall area
      wallArea = wallHeight * wallWidth;
      System.out.println("Wall area:  " + wallArea + " square feet");
  
      // Calculate and output the amount of paint (in gallons) needed to paint the wall
      gallonsPaintNeeded = wallArea/squareFeetPerGallons;
      System.out.println("Paint needed: " + gallonsPaintNeeded + " gallons");
  
  }
  }
  </code></pre>
  
  <p>The check that I'm trying to pass for the assignment is inputting a string instead of a double for the wallHeight. It prints "Invalid height" but then the program stops running and returns the error. How do I get it to continue running and prompt again for a valid input from the user?</p>