Question: Modify this c++ code which calculated the wind chill factor and cloud base altitude from inputs of temperature, wind speed, and the dew point, to
Modify this c++ code which calculated the wind chill factor and cloud base altitude from inputs of temperature, wind speed, and the dew point, to read the values from a file called weatherData.txt. Read the values, compute the results, and write the results to a file called yourName.txt and also display them on the output console. The data sentinel is -99.
The program must have at least four (4) functions: one for opening the files with file failure conditions, one to compute the wind chill, one to compute the cloud base, and at least one for the output. Consider other functions as you see fit.
Main will close the files before returning zero.
The input and output streams can be declared globally.
(Try not to use global variables)
The program must read the data from the data file weatherData.txt.
The program must produce the required output to the console window and to a file.
The output must be as shown in the screen capture below (notice the extra note shown).
The equations for the wind chill factor and computing cloud base are in the previous instructions.
The equation for approximating the wind chill factor in North America is:
wc = 35.74 + 0.6215 * Ta - 35.75 * V0.16 + 0.4275 * Ta * V0.16
The cloud base in feet above ground level is determined by the "spread" which is the difference between the temperature and the dew point, and is calculated:
cloudBase = temperature_spread / 4.4 * 1000;
Note: When the input does not produce a valid wind chill value, the program will need to retain this information to output the required text.
Output Formatting for the display and output file are to be exactly as shown below.

Orignal code:
// This program will be used for a meteorologist that calculates the wind chill factor and cloud base altitude for the inputs temperature in Fahrenheit, wind speed in mph, and the dew point in Fahrenheit. // Use a loop to enter a finite number of inputs for a given program run. //
#include
using namespace std; //Setting Variables and asking User to input data void takeInput(float *temp, float *wp, float *dp){ printf(" Enter the temprature in degrees Fahrenheit: "); scanf("%f",temp); printf("%.1f ",*temp); printf(" Enter the wind speed in mph: "); scanf("%f",wp); printf("%.1f ",*wp); printf(" Enter the dew point in degrees Fahrenheit: "); scanf("%f",dp); printf("%.1f ",*dp); } //setting vars. and calulating the wind chill float calculateWC(float &temp,float &wp){ return 35.74 + 0.6215*temp - 35.75*pow(wp,0.16) + 0.4275*temp*pow(wp,0.16); }
float calculateCB(float &temp,float &dp){ return (temp-dp)*1000/4.4; }
void showOutput(float temp,float wp,float dp,float wc,float cb){ std::cout =50||wp=50||wp
int main() { printf(" --------------------------------------------------------- | This program determines wind chill using temprature | | in Farhenheit and wind speed in mph. and computes | | the cloud base using the dew point in Fahrenheit | --------------------------------------------------------- "); printf(" "); float temp,wp,dp,wc,cb; takeInput(&temp,&wp,&dp); wc = calculateWC(temp,wp); cb = calculateCB(temp,dp); showOutput(temp,wp,dp,wc,cb); return 0; }
Test Input data-create a text file with the data below called "weatherData.txt" and test against the output shown above. The input data order is temperature, wind speed, dew point. 6 9.1 35 12 56 45 38 16 43 40 47 34 10 56 36 15
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
