/**
* Another example of a program that uses methods
*
* Also demonstrates some benefits of procedure abstraction
*
* @author (Michael Branicky)
* 09/12/2006
*/

import java.util.Scanner; // for user input

public class Weather
{
  // Convert from degrees Fahrenheit to degrees Celsius
  public static double convertF2C (double tempF) {
    return (tempF-32.0)/1.8;
  }

  // Compute the WindChill index (degrees F)
  public static double windChillIndex (double v, double t) {
    double v_part;  // local variable
    
    v_part = 0.474677 - 0.020425 * v + 0.303107 * Math.sqrt(v);
    return 91.4 - v_part * (91.4 - t);
  }

  public static void main(String args[])
  {
    // Create Scanner to obtain input from command window
    Scanner input = new Scanner( System.in );

    // Variables to be used
    double windSpeed, tempFahr, vPart, windChill;

    // Get user input
    System.out.print("Enter temp. (F) and wind speed (mph): ");
    tempFahr = input.nextDouble();
    windSpeed = input.nextDouble();

    // Display output
    System.out.printf("Temp. in Celsius is %f\n", convertF2C(tempFahr));
    
    windChill = windChillIndex(windSpeed, tempFahr);
    System.out.printf("Wind Chill index is %f F = %f C\n", windChill, convertF2C(windChill));
  }
}
