Assignemnt #69
Code
/// Name: Holden Ganch
/// Period: 7
/// Program Name: sixty nineth Program
/// File Name: Reverse.java
/// Date Finished: 1/11/2016
import java.util.Scanner;
public class Do
{
public static void main( String[] args ) throws Exception
{
Scanner keyboard = new Scanner(System.in);
String swimmer1 = "GALLANT"; // they swim for the same amount of time at 80.5 degrees
String swimmer2 = "GOOFUS"; // for the 78 swim swimmer2 swims more
// Gallant checks the water first but Goofus dives in before checking
//while variables check the data while do does a rotation before checking
// while = pre-test do = post-test
double minimumTemperature = 79.0;
double currentTemperature;
double savedTemperature;
int swimTime;
System.out.print("What is the current water temperature? ");
currentTemperature = keyboard.nextDouble();
savedTemperature = currentTemperature;
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);
currentTemperature -= 0.5;
System.out.println("\tThe current water temperature is now " + currentTemperature + "F.");
}
System.out.println( swimmer1 + " stops swimming. Total swim time: " + swimTime + " min");
currentTemperature = savedTemperature;
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");
}
}
Picture of the output