Assignment #69 and Do-While Swimming

Code

                          /// Name: Graham Pollock
                          /// Period: 5
                          /// Program Name: Do-While Swimming 
                          /// File Name: WhileSwimming.java
                          /// Date Finished: 12/15/2015/
                          
      import java.util.Scanner;
          
          public class WhileSwimming
          {
              public static void main( String[] args ) throws Exception
              {
                  Scanner keyboard = new Scanner(System.in);
          
                  String swimmer1 = "GALLANT";
                  String swimmer2 = "GOOFUS ";
          
                  double minimumTemperature = 79.0; // degrees Fahrenheit
                  double currentTemperature;
                  double savedTemperature;
                  int swimTime;
          
                  System.out.print("What is the current water temperature? ");
                  currentTemperature = keyboard.nextDouble();
                  savedTemperature = currentTemperature; // saves a copy of this value so we can get it back later.
          
                  System.out.println( "\nOkay, so the current water temperature is " + currentTemperature + "F." );
                  System.out.println( swimmer1 + " approaches the lake...." );
          
                  swimTime = 0;
                  while ( currentTemperature >= minimumTemperature )
                  {
                      System.out.print( "\t" + swimmer1 + " swims for a bit." );
                      swimTime++;
                      System.out.println( " Swim time: " + swimTime + " min." );
                      Thread.sleep(600); // pauses for 600 milliseconds
                      currentTemperature -= 0.5; // subtracts 1/2 a degree from the water temperature
                      System.out.println( "\tThe current water temperature is now " + currentTemperature + "F." );
                  }
          
                  System.out.println( swimmer1 + " stops swimming. Total swim time: " + swimTime + " min." );
          
                  currentTemperature = savedTemperature; // restores original water temperature
          
                  System.out.println( "\nOkay, so the current water temperature is " + currentTemperature + "F." );
                  System.out.println( swimmer2 + " approaches the lake...." );
          
                  swimTime = 0;
                  do
                  {
                      System.out.print( "\t" + swimmer2 + " swims for a bit." );
                      swimTime++;
                      System.out.println( " Swim time: " + swimTime + " min." );
                      Thread.sleep(600);
                      currentTemperature -= 0.5;
                      System.out.println( "\tThe current water temperature is now " + currentTemperature + "F." );
          
                  } while ( currentTemperature >= minimumTemperature );
          
                  System.out.println( swimmer2 + " stops swimming. Total swim time: " + swimTime + " min." );
              }
          }
      
      
          ///     When i change the statring temp to 80.5 they both swim for 4mins.
          ///     when i input 78 as the starting tempurature GALLANT swims for 0 minutes and GOOFUS swims for 1 minute
          ///     GALLANT checks the water first
          ///     GOOFUS just jumps right in then checks
          ///     A while loop checks the condition before =running the code while a do-while loop runs the code one time before checking the condition
          ///     Pre-test loop = while loop, post-test loop = do-while loop



    

Picture of the output

Assignment