Determine the daily min and max values of: Temperature, Pressure and Relative Humidity, Determine the daily max Wind Speed,
and Determine average Pressure, Relative Humidity and Wind Direction when rainfall is accumulated (display to console with single place after decimal)
Here is what I have in my code so far:
Code: Select all
///
///
///
///
///
/// Program: Weather data processing
/// Created by: Wesley Montgomery
/// This program anlizes weather data accessed from a file and finds the average of Temperature, Humidity, and other facts.
///
///
///
#include <fstream>
#include <iostream>
#include <string>
#include <cmath>
#include <stdlib.h>
#include <algorithm> // for min() and max()
#include <sstream>
#include <iomanip>
using namespace std;
void read_file(
ifstream& file, // The open and ready-to-read csv data file
string targetdate, // The date we are interested in (see note below)
int temp, // The index of the field we are interested in
double& min, // Where to put the minimum of the indexed field
double& max // Where to put the maximum
);
void read_filepres(
ifstream& file, // The open and ready-to-read csv data file
string targetdate, // The date we are interested in (see note below)
int pressure, // The index of the field we are interested in
double& min, // Where to put the minimum of the indexed field
double& max // Where to put the maximum
);
void read_filehum(
ifstream& file, // The open and ready-to-read csv data file
string targetdate, // The date we are interested in (see note below)
int humidity, // The index of the field we are interested in
double& min, // Where to put the minimum of the indexed field
double& max // Where to put the maximum
);
void read_filewindmax(
ifstream& file, // The open and ready-to-read csv data file
string targetdate, // The date we are interested in (see note below)
int wind, // The index of the field we are interested in
double& max // Where to put the maximum
);
void get_dates( ifstream& file, string dates[], int& size );
int main()
{
int pressure, temp, windspeed, humidity, rainfall, min_temp, max_temp, min_pres, max_pres, min_humi, max_humi, wind_max;
bool done; // exit flag
char selection; //Menu Selection
string file; // Name of datafile
ifstream weatherfile; //datafile stream
// Initialize exit flag
done = false;
while (!done)
{
// Output menu list
cout << "\n\n";
cout << "************************\n\n";
cout << " Weather Data Analysis: \n";
cout << " 1) Select Data File to be loaded\n";
cout << " 2) Daily Min/max of Temp,Pressure and humidity\n";
cout << " 3) Daily Max Wind Speed\n";
cout << " 4) Avg Pressure, Humidity, and Windspeed for rainy days\n";
cout << " 5) \n";
cout << " 6) Exit Program\n";
cout << "************************\n\n";
// Input data
cout << "Selection -> ";
cin >> selection;
cout << "\n\n";
// Process input
if (selection=='1')
{
cout << "Insert Data file:";
cin >> file;
weatherfile.open (file.c_str(), ios::in);
cout << "\n\n";
}
else if (selection=='2')
{
while (!weatherfile.eof())
{
string targetdate = "04/18/2008"; // whatever the target day is
read_file( weatherfile, targetdate, temp, min, max);
cout << targetdate << ": ";
cout << "The Minimum Temperature is" << setw(10) << setprecision(2) << min_temp << "degrees." << endl;
cout << "The Maximum Temperature is" << setw(10) << setprecision(2) << max_temp << "degrees." << endl;
read_filepres( weatherfile, targetdate, pressure, min, max);
cout << "The Minimum Pressure is" << setw(10) << setprecision(2) << min_pres << "millibars." << endl;
cout << "The Maximum Pressure is" << setw(10) << setprecision(2) << max_pres << "millibars." << endl;
read_filehum( weatherfile, targetdate, humidity, min, max);
cout << "The Minimum Humidity is" << setw(10) << setprecision(2) << min_humi << endl;
cout << "The Maximum Humidity is" << setw(10) << setprecision(2) << max_humi << endl;
}
weatherfile.clear();
weatherfile.seekg( 0 );
}
else if (selection=='3')
{
while (!weatherfile.eof())
{
string targetdate = "04/18/2008"; // whatever the target day is
read_filewindmax(weatherfile, targetdate, windspeed, max);
cout << targetdate << ": ";
cout << "The Maximum Wind Speed is" << setw(10) << setprecision(2) << wind_max << "miles per hour." << endl;
}
weatherfile.clear();
weatherfile.seekg( 0 );
}
else if (selection=='4')
{
while (!weatherfile.eof())
{
if (rainfall > 0)
{
}
}
weatherfile.clear();
weatherfile.seekg( 0 );
}
else if (selection=='5')
{
while (!weatherfile.eof())
{
}
weatherfile.clear();
weatherfile.seekg( 0 );
}
else if (selection=='6')
{
cout << "Goodbye. Thank you for using my program.\n\n";
done = true; // flag for exit
}
else
{
cout << "** Invalid Selection. **\n\n";
}
weatherfile.close();
} // end of while loop
return (0);
}
Can someone help me with this?