title: Return Switch case to main program in Java
body: <p>I know this is an easy question, but I am new to Java and am so lost. All that is left to do in my program is output a message saying something like "Invalid input, try again" at the end of each case in my program if the user does not enter either a yes or a no and return to the point where it asks for another calculation. I know it's elementary and I looked for an answer the best I could but I simply don't know enough of the java terminology. If you could help me I would appreciate it so much!</p>
  
  <p>P.S.It was pointed out to me that my variables should not begin with capital letters, I am aware and will not do it in the future.</p>
  
  <pre><code>    System.out.println(" The purpose of this program is to calculate the speed of sound through several mediums.\n The program user will input a distance in feet followed by a mediumd and the program will output the speed in feet per second and miles per hour\n");
      //declare variables
  
      Scanner keyboard = new Scanner(System.in);
  
      final double Air = 1126.1;
  
      final double Water = 4603.2;
  
      final double Steel = 20013.3;
  
      final double Earth = 22967.4;
  
      double OneFootPerSecond = .68181818182;
  
      double Distance;
  
      double AirSpeed;
  
      double WaterSpeed;
  
      double SteelSpeed;
  
      double EarthSpeed;
  
      boolean shouldContinue = true;
  
      while (shouldContinue == true){ 
  
      System.out.print(" What is the distance in feet:" );
      //ask the user to input variables
  
  
          while (!keyboard.hasNextDouble()){
          System.out.println("Please enter a valid numeric value, try again: ");
          keyboard.next();
          }
          Distance =keyboard.nextDouble();
          {
          System.out.print("Input the media: Air, Water, Steel, or Earth: ");
          String Input = keyboard.next();   
  
  
  
          switch(Input.toLowerCase())
  
           {
  
              case "air":
              AirSpeed = Distance/Air;
              System.out.print("\n \nThe time to for sound to travel ");
              System.out.print(Distance);
              System.out.print(" feet through AIR" +"\n");
              System.out.printf("%.6f", AirSpeed);
              System.out.print(" seconds or ");
              System.out.printf("%.1f", OneFootPerSecond*Air);
              System.out.print(" miles per hour."); 
              System.out.print("\n \nEnter Yes for another calculation, else No: ");
              String Another = keyboard.next();
              Another.toLowerCase();
             if (Another.equals("no")){
                 shouldContinue = false;
                                }
            if (!Another.equals("no"))
                if (!Another.equals("yes"))
                {System.out.print("Invalid.");
  
  
                }
  
  
              break;
  
  
  
       case "water":
              WaterSpeed = Distance/Water;
              System.out.print("\nThe time to for sound to travel ");
              System.out.print(Distance);
              System.out.print(" feet through WATER" +"\n");
              System.out.printf("%.6f",WaterSpeed);
              System.out.print(" seconds or ");
              System.out.printf("%.1f", OneFootPerSecond*Water);
              System.out.print(" miles per hour."); 
              System.out.print("\n \nEnter Yes for another calculation, else No: ");
              Another = keyboard.next();
              Another.toLowerCase();
               if (Another.equals("yes")){
                 shouldContinue = false;
  
             }
      break;
  
       case "steel":
              SteelSpeed = Distance/Steel;
              System.out.print("\nThe time to for sound to travel ");
              System.out.print(Distance);
              System.out.print(" feet through STEEL" +"\n");
              System.out.printf("%.6f",SteelSpeed);
              System.out.print(" seconds or ");
              System.out.printf("%.1f",  OneFootPerSecond*Steel);
              System.out.print(" miles per hour."); 
              System.out.print("\n \nEnter Yes for another calculation, else No: ");
              Another = keyboard.next();
              Another.toLowerCase();
               if (Another.equals("yes")){
                 shouldContinue = false;
  
             }
      break;     
  
            case "earth":
              EarthSpeed = Distance/Water;
              System.out.print("\nThe time to for sound to travel ");
              System.out.print(Distance);
              System.out.print(" feet through EARTH" +"\n");
              System.out.printf("%.6f",EarthSpeed);
              System.out.print(" seconds or ");
              System.out.printf("%.1f",  OneFootPerSecond*Earth);
              System.out.print(" miles per hour."); 
              System.out.print("\n \nEnter Yes for another calculation, else No: ");
              Another = keyboard.next();
              Another.toLowerCase();
               if (Another.equals("yes")){
                 shouldContinue = false;
  
             }
      break;
      default :
              System.out.print("Invalid. Re-run the program. ");                  
       break;                      
          }
         }  
  </code></pre>