title: JAVA: Runtime Exception (I think that's what i need to use)
body: <p>Ok, I need my program to validate user entered data.  If that data is invalid, the program needs to skip almost all of my code and get to the end of my while loop to ask if the user would like to proceed with calculating another loan.  My professor has not provided us with a method of doing this and all the information ive found on the internet is not specific enough to help me.  Once again, I need the code after the validation to be skipped without exiting the program and go to the end of the loop where I ask the user if they want to calculate another loan.  Here is my code thus far.</p>
  
  <pre><code>        /*  This program is an extension of the previous Interest Calculator.  The only different is this one can
      compute not only simple interest but daily and monthly compound interest using a switch statement to
      differentiate each type of interest.    */
  
  import javax.swing.*;
  // Import the GUI methods
  public class InterestCalculatorLoop {
      public static void main(String[] args) {
      // Entry point of program
          String again = "yes";
          while (again.equalsIgnoreCase("yes" ))
          {
              String option = JOptionPane.showInputDialog("Which type of loan would you like to find interest for? \n1 = Simple Interest \n2 = Monthly Compounded Interest \n3 = Daily Compounded Interest");
              int optionInt = Integer.parseInt(option);
              int interestType = Integer.parseInt(option);
              String paString = JOptionPane.showInputDialog("Enter the principal amount");
              double pa = Double.parseDouble(paString);
              double interest = 0;
              double months = 0;
              double totalInterest = 0;
              double years = 0;
              final double daysInYear = 365.0;
              final double daysInMonth = 30.41666666667;
              final double monthsInYear = 12.0;
  
              // Logic statements to validate user input or otherwise run through the rest of the program without calculation
              if (pa &lt;= 0)
              {
                  JOptionPane.showMessageDialog(null, "Data Error: The principal amount must be greater than zero.  You entered " + pa);
                  return;
              }
              else
              {
                  String interestString = JOptionPane.showInputDialog("Enter The Annual Interest Rate [1 - 100 percent]) ");
                  interest = Double.parseDouble(interestString);
              }
                  if (interest &lt; 0 || interest &gt; 100)
                  {
                      JOptionPane.showMessageDialog(null, "Data Error: The interest amount must be between 1 and 100. You entered " + interest);
                      return;
                  }
                  else
                  {
                      String monthsString = JOptionPane.showInputDialog("Enter the number of months");
                      months = Double.parseDouble(monthsString);
                  }
                      if (months &lt;= 0)
                      {
                          JOptionPane.showMessageDialog(null, "Data Error: The number of months must be above 0.  You entered " + months);
                          return;
                      }
                      else
                      {
                          switch (optionInt)
                          {
                          // Case for simple intrest
                          case 1: optionInt = 1;
                              months = months/monthsInYear;
                              totalInterest = pa * (interest/100.0) * months;
                              JOptionPane.showMessageDialog(null, "The total amount of interest of your loan is $" + totalInterest + ".");
                              break;
  
                          // Case for monthly compounded interest
                          case 2: optionInt = 2;
                              interest = interest/100.0;
                              years = months/monthsInYear;
                              double exponent = months*years;
                              double interestOverMonths = 1+interest/months;
                              double thirdTotal = Math.pow(interestOverMonths, exponent);
                              double secondTotal = pa*thirdTotal;
                              totalInterest = secondTotal - pa;
                              JOptionPane.showMessageDialog(null, "The total amount of interest of your loan is $" + totalInterest + ".");
                              break;
  
                          // Case for daily compounded interest
                          case 3: optionInt = 3;
                              interest = interest/100.0;
                              double days = months*daysInMonth;
                              years = days/daysInYear;
                              exponent = days*years;
                              double interestOverDays = 1+interest/days;
                              thirdTotal = Math.pow(interestOverDays, exponent);
                              secondTotal = pa*thirdTotal;
                              totalInterest = secondTotal - pa;
                              JOptionPane.showMessageDialog(null, "The total amount of interest of your loan is $" + totalInterest + ".");
                              break;
                          }
                      }
                      again = JOptionPane.showInputDialog("Would you like to compute another loan? (yes or no)");
  
          }
  
      }
  }
  </code></pre>