WindChillTemperature In class Exercise
// Solution to the In class Wind Chill Temperature Problem | |
// A.C. Silvestri | |
// 10/01/18 | |
// CSC-111 | |
// https://www.weather.gov/epz/wxcalc_windchill | |
package chapter3; | |
import java.util.Scanner; | |
public class WindChillTemperature { | |
public static void main(String[] args) { | |
Scanner input = new Scanner(System.in); | |
System.out.print("Enter Wind Speed: "); | |
double speed = input.nextDouble(); | |
if (speed < 2) | |
System.out.println("Bad Speed Entered (< 2.0) Aborting..."); | |
else { | |
System.out.print("Enter Real Temperature: "); | |
double fahrenheit = input.nextDouble(); | |
if (fahrenheit < -58.0) | |
System.out.println("Bad Temperature Entered (< -58 or > 41) Aborting..."); | |
else if (fahrenheit > 41.0) | |
System.out.println("Bad Temperature Entered (< -58 or > 41) Aborting..."); | |
else { | |
// Compute wind chill index | |
double windChillIndex = 35.74 + 0.6215 * fahrenheit - 35.75 * | |
Math.pow(speed, 0.16) + 0.4275 * fahrenheit * | |
Math.pow(speed, 0.16); | |
System.out.printf("Wind Chill Temperature = %.1f\n", windChillIndex); | |
} | |
} | |
input.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment