Skip to content

Instantly share code, notes, and snippets.

@bytecodeman
Created October 8, 2018 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bytecodeman/6c8c27e4178965df0841be7b699f22bd to your computer and use it in GitHub Desktop.
Save bytecodeman/6c8c27e4178965df0841be7b699f22bd to your computer and use it in GitHub Desktop.
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