Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You are working on a project that requires climate data for a location. The maxi

ID: 3603067 • Letter: Y

Question

You are working on a project that requires climate data for a location. The maximum daily change in barometric pressure is one aspect of climate that your company needs. You have a file (barometric.dat) containing hourly barometer readings taken over the course of a year. Each line of the file contains the readings for a single day, separated by blanks. Each reading is expressed in inches of mercury, so it is a decimal number ranging from approximately 28.00 to 32.00. For each line of data, you need to determine the maximum and minimum readings, and output the maximum, minimum, and their difference between those readings to file differences.dat. Each day's output value should appear on a separate line of the file. Once the file has been read, the program should output the greatest and least differences for the year on cout. Develop a C++ program using functional decomposition, and use proper style and documentation in your code. Your program should make appropriate use of value-returning functions in solving this problem.

Explanation / Answer

or

Here is the code I got to work
#include <iostream>
#include <string>
#include <fstream>

using namespace std;

float MinMaxDiff (ifstream& inData, // To establish the subfunction
float& yearlymin,
float& yearlymax);
int main()
{
static float yearlymin;
static float yearlymax;
yearlymin = 32.0;
yearlymax = 28.0;

ifstream inData; //Opens the input file
inData.open ("C:\Users\Documents\barometric.dat");

ofstream outputFile; //Opens the output file
outputFile.open ("C:\differences.dat");

for (int i = 0; i < 365&& inData; i++)
{
float diff;
diff = MinMaxDiff(inData, yearlymin, yearlymax);
outputFile << diff << endl;

}
cout << "The Yearly Max is: " << yearlymax << endl;
cout << "The Yearly Min is: " << yearlymin << endl;

system ("PAUSE");

return 0;


}

float MinMaxDiff (ifstream& inData,
float& yearlymin,
float& yearlymax)
{
float min = 32.0;
float max = 28.0;
float num = 0;
inData >> num;

for (int i=0; i < 24&& inData; i++)
{
if(num > max)
{
max = num;
}
if(num < min)
{
min = num;
}
if(num > yearlymax)
{
yearlymax = num;
}
if(num < yearlymin)
{
yearlymin = num;
}
inData >> num;
}
return max - min;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote