Advertisements

Wind chill

Given the temperature t (in Fahrenheit) and the wind speed v (in miles per hour), the National Weather Service defines the effective temperature (the wind chill) to be:

w = 35.74 + 0.6215 t + (0.4275 t – 35.75) v0.16

Write a program WindChill.java that takes two double command-line arguments t and v and prints out the wind chill. Use Math.pow(a, b) to compute ab. Note: the formula is not valid if t is larger than 50 in absolute value or if v is larger than 120 or less than 3 (you may assume that the values you get are in that range).

 

Advertisements

About Rant4u

A Revolution in Social Networking

Posted on February 18, 2014, in Java programming and tagged , , , , , , . Bookmark the permalink. 1 Comment.

  1. import java.lang.Math;
    import java.lang.String;

    public class WindChillRedo{

    public static void main(String args[])
    {
    System.out.println(“What is the temperature is “); //This prompts the user to enter a number
    int t = parseInt(args[0]);

    System.out.println(“Enter what the wind speed is “); //This prompts the user to enter a 2nd number
    double v = scan.nextDouble(); //Stores the valuse as a double

    double w = 35.74 + 0.6215*t + (0.4275*t – 35.75) * Math.pow(v, 0.16); //formula for wind chill given by http://introcs.cs.princeton.edu/java/12types/WindChill.java.html
    System.out.println(“Temperature = ” + t); //Prints what the temperature is
    System.out.println(“Wind speed = ” + v); //Prints what the Wind Speed is
    System.out.println(“Wind chill = ” + w); //Prints what the Wind chill is

    }
    }

    Liked by 1 person

Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: