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
|
#include <iostream>
#include <fstream>
#include <math.h>
#include <string>
#include <cstdlib>
using namespace std;
int main()
{
const int MAX = 100;
int dataEntry, day[MAX], menuSelection, desiredDay, selectedField, dayOne, dayTwo,
decade;
double highTemp[MAX], recordHigh[MAX], humidityPercent[MAX], yearRecord[MAX],
heatIndex, Adjustment, minValue, maxValue, averageValue, valueRange,
sum, numDifference, largestDiff;
int ix = 0;
int count = 0;
string filename;
ifstream infile;
cout << endl << "Weather Station Records of Temperatures and Humidity"
<< endl << endl;
do
{
cout << "Please choose from the following" << endl;
cout << "(1) Enter data through keyboard" << endl;
cout << "(2) Enter data through a data file" << endl;
cout << "Please enter your selection now: ";
cin >> dataEntry;
if (dataEntry <= 0 || dataEntry > 2)
{
cout << endl << "Please enter one or two" << endl << endl;
}
}
while (dataEntry <= 0 || dataEntry > 2);
if (dataEntry == 1)
{
do
{
cout << endl << "Enter the five data fields. "
"When you are done enter 0 for the day." << endl;
cout << endl << "Enter the day " << endl;
cout << "(Counting from the beginning of the year for example: "
"February 2 is 33): ";
cin >> day[ix];
count = count + 1;
if (day[ix] == 0) break;
{
cout << endl << "Enter the high temperature (degrees Fahrenheit): ";
cin >> highTemp[ix];
cout << endl << "Enter the record high temperature "
"(degrees Fahrenheit): ";
cin >> recordHigh[ix];
cout << endl << "Enter the year the record high temperature"
" was recorded: ";
cin >> yearRecord[ix];
cout << endl << "Enter the relative humidity (in percent): ";
cin >> humidityPercent[ix];
++ix;
}
}
while (ix < MAX);
}
else
{
cout << endl << "Please enter the name of the file you wish to open: ";
cin >> filename;
infile.open(filename.c_str());
if (infile.fail())
{
cout << endl << "The file named " << filename
<< " was not successfully opened"
exit(1);
}
else
{
cout << "\nThe file was successfully opened." << endl;
}
}
|