The user should be able to enter a temperature and wind


Exercise 11.2

In the winter, weather reports often refer to the wind-chill factor, a measurement that combines Ami¬d temperature and wind speed to estimate the temperature experienced by an exposed human hem", If the wind speed is 3 miles per hour or less, then the wind is not considered a factor in the experic Thad cmperature-i.e., the wind chill is the same as the actual temperature. If the wind speed exceei% niles per hour, however, meteorologists use a complex formula to compute the wind chill. Assur.-..:is hat temperature stores the actual temperature (in degrees Fahrenheit) and windSpeed store, ire Nind spccd (in miles per hour), we can calculate the wind-chill factor using the following formula

temperature
1if windSpeed s 3
.E-
vindChill = 35.74 + 0.6215*temperature +
(0.4275-temperature - 35.75)*windSpeedr lb otherwise

When translated into JavaScript, the formula for calculating wind chill can be written using the lc& owing if statement:

if (windSpeed <= 3)
windChill = temperature;

else {
windChill = 35.74 + 0.6215*temperature +
(0.4275*temperature - 35.75)*Math.pow(windSpeed, 0.16);
}

Create a Web page named chi 1 1 . html that computes the wind-chill factor for a given temperature and wind speed. The user should be able to enter a temperature and wind speed via text boxes, then click a button to view the corresponding wind-chill factor in a separate text box. As part of your page, you should define a function named Wi ndChi 11 that accepts the temperature and wind speed as in¬puts and returns the wind-chill factor.

Once you have completed your page, use it to determine the wind-chill factors for the following weather conditions:
wind = 2 temp = 30
wind = 5 temp = 18
wind = 12 temp = 45
wind = 30 temp = 10

 

Solution Preview :

Prepared by a verified Expert
Programming Languages: The user should be able to enter a temperature and wind
Reference No:- TGS01245215

Now Priced at $20 (50% Discount)

Recommended (93%)

Rated (4.5/5)