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 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.

I will have a .txt file already I was just wondering where would I need to add those strings to let it read the .txt file and output to a .txt file?

Orignal code:

#include

#include

void input(double *temperature,double *windSpeed,double *duePoint);

void output(double *temperature,double *windSpeed,double *duePoint,double windChill,double cloudBase);

double computeWindChill(double *temperature,double *windSpeed);

double computeCloudBase(double *temperature,double *duePoint);

int main()

{

//Declare all variables

double *temperature= new double;

double *windSpeed= new double;

double *duePoint = new double;

double windChill = 0;

double cloudBase = 0;

//Get input

input(temperature,windSpeed,duePoint);

//Compute only if temperature is =3

if(*temperature=3) {

//Call computeWindChill method

windChill= computeWindChill(temperature,windSpeed);

}

//Call computeCloudBase method

cloudBase= computeCloudBase(temperature,duePoint);

//Print output

output(temperature,windSpeed,duePoint,windChill,cloudBase);

return 0;

}

//Method to get input

void input(double *temperature,double *windSpeed,double *duePoint)

{

std::cout

std::cout

std::cout

std::cout

std::cout

std::cout

std::cin>>*temperature;

std::cout

std::cin>>*windSpeed;

std::cout

std::cin>>*duePoint;

}

//Method to print output

void output(double *temperature,double *windSpeed,double *duePoint,double windChill,double cloudBase)

{

std::cout

std::cout

if(*temperature=3)

{

std::cout

}

else

{

std::cout

std::cout

}

}

//Method to compute wind chill and return wind chill

double computeWindChill(double *temperature,double *windSpeed)

{

double windChill;

windChill = 35.74 + 0.6215 *(*temperature) - 35.75*(pow(*windSpeed,0.16))+ 0.4275*(*temperature)*(pow((*windSpeed),0.16));

//35.74 + 0.6215*(*temperature) - 35.75*(*windSpeed) +0.16 + 0.4275 *(*temperature)*(*windSpeed) +0.16;

return windChill;

}

//Method to compute cloud base

double computeCloudBase(double *temperature,double *duePoint)

{

double cloudBase;

cloudBase = (*temperature - *duePoint)/4.4 * 1000;

return cloudBase;

}

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!