Assignemnt #69 and DoWhileSwimming.java

Code

    /// Name: Boris Kazantsev
    /// Period: 6
    /// Program Name: DoWhileSwimming
    /// File Name: DoWhileSwimming.java
    /// Date Finished: 1/14/2016
    
    import java.util.Scanner;
    
    public class DoWhileSwimming
    {
        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." );
        }
    }
    
    // #1 Yes
    // #2 Goofus swims for a minute, but Gallant doesn't swim.
    // #3 Gallant checks the temperature before
    // #4 Goofus dives in
    // #5 "while" does the action when the condition is appropriate, but "do-while" does the action first and does the action depends on the condition
    // #6 pre-test loop is while loop and post-test loop is do-while loop             
    

Picture of the output

Assignment 69