I have posted questions about this HW the other day, and I would like to know if I am going in the right direction with this program, it is next in sequence from last problem. I would ask my professor but he never responds to my emails.
Prompt:
INTERACTIVE DATA PROCESSING
4. (60 Points) Using the five-column data file produced by problem 2 above write a program that gives the user five options as described by a-e below.
The program should provide a menu showing each of the five options. The user then selects one of the five options. Depending on the option the user will be prompted to enter the corresponding parameters. Then those parameters will be passed to a function to do the work.
A: (12 Points) Total Precipitation from all stations for a single day
User enters one day in mm dd yyyy format. Program returns total precipitation from all stations in inches for that date.
TEST CASES: March 10, March 20.
B: (12 Points) Total Precipitation over a range of dates.
User specifies start date and end date in mm dd yyyy format. Program returns total precipitation from all stations over the date range.
TEST CASE: 03 07 2018 through 03 12 2018
C: (12 Points) Total Precipitation by Station for March.
User enters station name. The program adds up the precipitation for the entire month from that station - or group of stations. (NOTE: Entering DECATUR will select all stations with DECATUR as all or part of the station name.)
TEST CASES: HUNTSVILLE, ATHENS
D: (12 Points) Temperature Extremes and Average by Station
User enters station name. e.g. BANKHEAD. The program finds and returns the maximum temp, minimum temp, average high temperature, and average low temperature for station during March. You must calculate the average high and the average low from the tmax and tmin values. (Station names must match exactly.)
TEST CASES: MOBILE DOWNTOWN AIRPORT, DECATUR PRYOR FIELD
E. (12 Points) Temperature Extremes and Average by Station over a range of dates
User enters station name, start date and end date in mm dd yyyy format. The program computes and returns the maximum temp, minimum temp, average high temperature, and average low temperature for the specified station over the date range. You must calculate the average high and the average low from the tmax and tmin values. (Station names must match exactly.)
TEST CASES: BIRMINGHAM AIRPORT 03 05 2018 03 15 2018
SCOTTSBORO 03 20 2018 03 31 2018
(NOTE: There is also a SCOTTBORO 2 weather station. Do not include its data in the SCOTTSBORO test case.)
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
|
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
string dataline = "";
string station = "";
string tmax_s = "", tmin_s = "";
unsigned int pos_station_name = 0;
unsigned int pos_date = 0;
unsigned int pos_tmax = 0;
unsigned int pos_tmin = 0;
unsigned int mm = 0, dd = 0, yyyy = 0;
float tmax = 0, tmin = 0;
ifstream infile;
infile.open("/Users/adam/desktop/temp/weather_station_five_column10.txt");
if (!infile)
{
cout << "Unable to open the input file\n";
return -99;
}
cout << "Use the first line of the file to find the column positions. " << endl;
getline(infile,dataline);
cout << "Read the second line from the file. " << endl;
getline(infile,dataline);
cout << "Read the data items one at a time." << endl;
infile >> station;
char choice;
//unsigned short response = 0;
bool menuQuit = false;
while (menuQuit == false)
{
do
{
cout << "What action would you like to take?\n"
<< " A) Total Precipitation over a single day\n"
<< " B) Total Precipitation over range of dates\n"
<< " C) Total Precipitation by Station for March\n"
<< " D) Temperature Extremes and Average by Station\n"
<< " E) Temperature Extremes and Average by Station over a range of dates\n"
<< " F) Exit\n"
<< ": ";
cin >> choice;
cout << "\n";
}
while (choice != 'F');
switch (choice)
{
case 'A':
cout << "Please enter date mmddyyyy\n\n";
cin >> mm >> dd >> yyyy;
break;
case 'B':
cout << "B selected\n\n";
break;
case 'C':
cout << "C selected\n\n";
break;
case 'D':
cout << "D selected\n";
break;
case 'E':
cout << "D selected\n";
break;
case 'F':
cout << "exiting.....\n";
menuQuit = true;
break;
default:
cout << "\n** Invalid Menu Selection!! **\n\n";
break;
}
}
return 0;
}
|
Data file I made from last question:
STATION_NAME DATE PRCP TMAX TMIN
--------------------------------------------------- -------- -------- -------- --------
BANKHEAD LOCK AND DAM AL US 20180301 0.15 46.76 41.54
BANKHEAD LOCK AND DAM AL US 20180302 0.45 46.94 39.92
BANKHEAD LOCK AND DAM AL US 20180303 0 46.94 37.94
BANKHEAD LOCK AND DAM AL US 20180304 0 46.76 37.94
BANKHEAD LOCK AND DAM AL US 20180305 0 43.7 38.48
BANKHEAD LOCK AND DAM AL US 20180306 1.36 43.88 38.66
BANKHEAD LOCK AND DAM AL US 20180307 0.41 41.72 38.12
BANKHEAD LOCK AND DAM AL US 20180308 0 41.18 37.22
BANKHEAD LOCK AND DAM AL US 20180309 0 41.36 37.22
BANKHEAD LOCK AND DAM AL US 20180310 0 43.34 37.4
BANKHEAD LOCK AND DAM AL US 20180311 0.89 44.6 40.46
BANKHEAD LOCK AND DAM AL US 20180312 0.1 44.6 38.12
BANKHEAD LOCK AND DAM AL US 20180313 0 42.44 37.94
BANKHEAD LOCK AND DAM AL US 20180314 0 42.26 37.58
BANKHEAD LOCK AND DAM AL US 20180315 0 41.9 38.12
BANKHEAD LOCK AND DAM AL US 20180316 0 44.24 38.12
BANKHEAD LOCK AND DAM AL US 20180317 0.15 43.52 40.28
BANKHEAD LOCK AND DAM AL US 20180318 0 46.04 42.44
BANKHEAD LOCK AND DAM AL US 20180319 0.17 44.78 42.44
BANKHEAD LOCK AND DAM AL US 20180320 0.04 45.68 41.72
BANKHEAD LOCK AND DAM AL US 20180322 0 43.16 38.12
BANKHEAD LOCK AND DAM AL US 20180323 0 44.24 38.66
BANKHEAD LOCK AND DAM AL US 20180324 0 45.86 39.56
BANKHEAD LOCK AND DAM AL US 20180325 0.01 45.68 41.9
BANKHEAD LOCK AND DAM AL US 20180326 0 45.86 40.82
BANKHEAD LOCK AND DAM AL US 20180327 0 41.72
|