ENGR 131: Wind Chill Example
Problem Statement / Formulas
Corresponding Java Program
import java.util.Scanner; // For user input
/**
* Compute wind chill given temp. in Fahrenheit and wind speed in miles per hour
* Ref.: J. Adams et al., C++: An Intro. to Computing
*
* @author (Michael Branicky) 09/07/2006, modified 09/05/2007
*/
public class WindChill
{
public static void main(String args[])
{
// Declaration of variables to be used
double windSpeed, tempFahr, vPart, windChill;
// Create Scanner to obtain input from command window
Scanner input = new Scanner( System.in );
// Get user input
System.out.print("Enter temp. (F): ");
tempFahr = input.nextDouble();
System.out.print("Enter wind speed (mph): ");
windSpeed = input.nextDouble();
// compute v_part
vPart = 0.474677 - 0.020425 * windSpeed + 0.303107 * Math.sqrt(windSpeed);
// compute wind chill
windChill = 91.4 - vPart * (91.4 - tempFahr);
// Display output
System.out.println("Wind Chill index = " + windChill);
}
}
Created: 2007-09-05.
Last Modified: 2007-09-05. © Michael S. Branicky