1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
|
//PUT SEMICOLONS ON WHERE THEY NEED TO BE~!!!!
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <array>
#include <istream>
using namespace std;
int ReadyFiles(tempData, atmData, precData, winterOut, springOut, summerOut,fallout);
int ReadFiles(tempData, atmData, precData, dailyWeaRec, validDate);
int ReadyFiles(ifstream& tempData, ifstream& atmData, ifstream& precData, ofstream& winterOut, ofstream& springOut, ofstream& summerOut, ofstream& fallOut);
enum Season {WINTER, SPRING, SUMMER, FALL};
struct WeatherData // Holds weather data from all three files
{
string date; // Date of observation
int highTemp; // High temperature recorded
int lowTemp; // Low temperature recorded
int avgTemp; // Average temperature for date
int departNorm; // Departure from normal temperature
int avgDP; // Average dew point for the date
int avgRH; // Average relative humidity for the date
int avgWind; // Average wind speed recorded for the date
float avgPress; // Average barometric pressure for the date
float totPrecip; // Total precipitation for the date, (-1 if none)
int noObs; // Number of observations taken for the date
};
struct YearStats // Holds the yearly totals, highs, lows for summary
{
int highTemp; // Highest temp encountered for year so far
string highTempDate; // Date of highest temp encountered
int lowTemp; // Lowest temp encountered for year so far
string lowTempDate; // Date of the lowest temp encountered
float highPrecip; // Highest precipitation encountered for year so far
string highPrecDate; // Date of highest precipitation encountered
int totHigh; // Accumulator for high temperatures
int totLow; // Accumulator for low temperatures
int totDP; // Accumulator for dew points
int totRH; // Accumulator for relative humidities
int totWind; // Accumulator for wind speeds
float totPress; // Accumulator for barometric pressures
float totPrecip; // Accumulator for precipitation
int obsCnt; // Counter of number of dates for averages
};
struct SeasonStats // Holds the season totals for summary
{
int totHigh; // Accumulator for high temperatures
int totLow; // Accumulator for low temperatures
int totDP; // Accumulator for dew points
int totRH; // Accumulator for relative humidities
int totWind; // Accumulator for wind speeds
float totPress; // Accumulator for barometric pressures
float totPrecip; // Accumulator for precipitation
int obsCnt; // Counter of number of dates for averages
};
int main()
{
WeatherData dailyWeaRec;
Season curSeason;
YearStats curYearStats;
SeasonStats winterStats, springStats, summerStats, fallStats;
ifstream tempData, atmData, precData;
ofstream winterOut, springOut, summerOut, fallout;
bool validDate = true;
bool firstRec = true;
bool newYear;
ReadyFiles(tempData, atmData, precData, winterOut, springOut, summerOut,fallout);
//V change to actual code
if (!ReadyFiles(tempData, atmData, precData, winterOut, springOut, summerOut,fallout))
{
cout << "print error message to screen";
exit(exit_code);
}
ReadFiles(tempData, atmData, precData, dailyWeaRec, validDate);
while (tempData not eof and validDate){
newYear = CheckNewYear (dailyWeaRec.date) //have I encountered a new year
if (newYear)
if (firstRec) // I will get a new year for first record, but don’t
firstRec = false // print stats
else
OutputStats(curSeason,curYearStats, winterStats, springStats,
summerStats, fallStats)
ResetStats(dailyWeaRec, curYearStats, winterStats, springStats,
summerStats, fallStats)}
curSeason = ProcessSeason(dailyWeaRec.date)
switch (curSeason)
case (WINTER): CreateOutputRec(dailyWeaRec, winterOut)
ComputeStats(dailyWeaRec, curYearStats, winterStats)
case (SPRING): CreateOutputRec(dailyWeaRec, springOut)
ComputeStats(dailyWeaRec, curYearStats, springStats)
case (SUMMER): CreateOutputRec(dailyWeaRec, summerOut)
ComputeStats(dailyWeaRec, curYearStats, summerStats)
case (FALL): CreateOutputRec(dailyWeaRec, fallOut)
ComputeStats(dailyWeaRec, curYearStats, fallStats)
Readfiles(tempData, atmData, precData, dailyWeaRec, validate)
endwhile;
if (validDate){ // as long as invalid dates did not cause loop exit
OutputStats (curSeason, curYearStats, winterStats, springStats,
summerStats, fallStats);
}
CloseFiles(tempData, atmData, precData, winterOut, springOut, summerOut,
fallout);
return 0;
}
void ReadyFiles(ifstream& tempData, ifstream& atmData, ifstream& precData,
ofstream& winterOut, ofstream& springOut,
ofstream& summerOut, ofstream& fallOut);
{
cout << "input the temperature file " << endl;
getline(cin, tempData);
file.open(tempData.c_str());
cout << "input the atmosphere file " << endl;
getline(cin, atmData);
file.open(atmData.c_str());
cout << "input the precipitation file " << endl;
getline(cin, precData);
file.open(precData.c_str());
file.open(winterOut.c_str());
file.open(springOut.c_str());
file.open(summerOut.c_str());
file.open(fallOut.c_str());
return;
}
void ReadData(ifstream& tempData, ifstream& atmData, ifstream& precData,
WeatherData& dailyWeaRec, bool& validDate);
{
//V turn into actual code~~!!!!!!!
read tempDate
read atmDate
read precDate
if (tempDate == atmDate) and (atmDate == precDate)){
read fields from files into dailyWeaRec members
set validDate to true
}
{else
cout << "print dates don't match message to screen" << endl;
set validDate to false
}
return;
}
|