title: going back to the beginning of a program
body: <p>Hi I am new to java at the moment. I have a working code but I want it to go back to the beginning if the user types in the time wrong. and i cant seem to work it out, is there a simple way i can do it.</p>
  
  <pre><code>    package Time_calculation;
  
      import java.util.*;
      import java.text.SimpleDateFormat;
      import java.util.Date;
  
      public class Time_calculation {
  
      public static void main(String[] args) {
  
      SimpleDateFormat timeFormat =  new SimpleDateFormat ("HH:mm:ss");
  
      Date T1 = null;
      Date T2 = null;
  
  
      Scanner RFK = new Scanner(System.in);
  
      boolean programrunning = true;
      while (programrunning == true){
  
  
      System.out.println("Enter start time HH:MM: (If you wish to exit please type 'Exit')");
      String srtTime = RFK.nextLine();
      if (srtTime .matches ("Exit")){
              System.out.println("Exiting...");
              System.exit(0); 
      }else{
      try{
          T1 = timeFormat.parse(srtTime);
          }catch (Exception e){
              System.err.println("Error");}
  
  
      System.out.println("Enter end time HH:MM:SS (If you wish to exit please type 'Exit')");
      String endtime = RFK.nextLine();
      if (endtime .matches ("Exit")){
              System.out.println("Exiting...");
              System.exit(0); 
      }else{
      try{   
          T2 =timeFormat.parse(endtime);
          }catch (Exception e){
              System.err.println("Error");}
  
      long diff = T2.getTime() - T1.getTime();
      long diffsec = diff / 1000;
      System.out.println("Your time in seconds is: " + diffsec + " seconds");
  
      double ms = 1609.344 / diffsec;
      double mph = ms * 2.23693629;
      System.out.println("Speed in M/S: " + ms);
      System.out.println("Speed in MPH is: " + mph);
  
      if(mph &gt; 6){
             System.out.println("Running faster than average speed!");}
      else{
             System.out.println("You are running lower than average speed!");}
  
      System.out.println();
             }
          }
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>has anyone got any ideas how, it would really help.    </p>