Question
Write a program in C The program for this lab will calculate the Wind Chill Index (T wc ), given an air temperature (T a
Write a program in C
The program for this lab will calculate the Wind Chill Index (Twc), given an air temperature (Ta) in degrees Fahrenheit, and a wind speed (V) in miles per hour.
Your program will prompt the user to enter two values. The first value will be a temperature in degrees Fahrenheit, and will be of type int. The second value will be the wind speed in miles per hour, and will be of type double. You will use the following formula to calculate the Wind Chill Index which will be of type double: Twc = 35.74 + 0.6215Ta - 35.75V+0.16 + 0.4275TaV+0.16
Note that there are five constants in the above formula. You will use the pre-processing directive #define to express the first three constants: 35.74, 0.6215, and 35.75 (which will be named CONST_ONE, CONST_TWO, and CONST_THREE). You will use global constant declarations for the last two values: 0.16 and 0.4275 (which will be named EXPONENT and CONST_FOUR). The actual line(s) of code that calculates the wind chill will contain no digits.
Once you have calculated the Wind Chill Index, you will then display the temperature, wind speed and wind chill using descriptive statements such as:
Temperature: 38 degrees Fahrenheit Wind Speed: 17.4 mph Wind Chill Index: 28.6 degrees Fahrenheit
Floating point numbers should be output to one decimal place. Also, values of a magnitude less than 1 should display a leading 0 (ex. 0.7). Even though the temperature will be read as type int and wind speed will be read as a type double, the user may or may not enter values with a decimal point. In other words, expect the user to enter values such as 25, 25.0 and 25.35 for both temperature and wind speed.
Note that wind chill calculations only work correctly for temperatures below 50 degrees Fahrenheit and wind speeds above 3 mph. For this lab, you must check inputs to ensure that the values are within a proper range. If an improper value is entered (temperature is >= 50 or wind speed <= 3.0), an error message will be printed and the program will exit (do not re-prompt the user for a correct value). You may assume for error checking purposes, that only numerical values will be entered by the user.
For input, you must use the fgets()/sscanf() combination of Standard I/O functions. Do not use the scanf() or fscanf() functions. Although using scanf() for retrieving numerical data is convenient, it is problematic when used in conjunction with character string input. Therefore, it is best to get into the habit of using the fgets()/sscanf() combination exclusively.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started