Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #include <fstream>
- int day[365];
- double htemp[365];
- double ltemp[365];
- double windspeed[365];
- double humidity[365];
- void getinfo( int& ix, int& datatotal );
- void mainmenu( int datatotal, int ix );
- void menuselection ( int choice, int datatotal, int ix );
- void displaydata( int datatotal, int ix );
- int main()
- {
- int datatotal;
- int ix = 0;
- cout << "Welcome to the Weather Station Program" << endl;
- cout << endl;
- getinfo( ix, datatotal );
- ix = 0;
- mainmenu( datatotal, ix );
- return 0;
- }
- void getinfo( int& ix, int& datatotal )
- {
- char kord;
- do
- {
- cout << "Would you like to enter the data from the keyboard or a data file?" << endl;
- cout << "(enter k for keyboard or d for data file): ";
- cin >> kord;
- }
- while( kord != 'k' && kord != 'd' );
- if ( kord == 'd' )
- {
- cout << endl;
- cout << "Enter the path for the data file." << endl;
- cout << "(for example C:\\Temp\\weatherdata.txt): ";
- cout << endl;
- }
- else
- {
- cout << endl;
- cout << "Please enter the following data. When you are done entering the data," << endl;
- cout << "enter in 0 for the day entry" << endl;
- int ix = 0;
- do
- {
- cout << endl;
- cout << "Enter the Day number (maximum of 365): ";
- datatotal = ix;
- cin >> ix;
- day[ix] = ix;
- if( ix == 0 )
- {
- cout << endl;
- }
- else
- {
- cout << endl;
- cout << "Enter the High Temperature of the day: ";
- cin >> htemp[ix];
- cout << endl;
- cout << "Enter the Low Temperature of the day: ";
- cin >> ltemp[ix];
- cout << endl;
- cout << "Enter the High Windspeed of the day: ";
- cin >> windspeed[ix];
- cout << endl;
- cout << "Enter the Relative Humidity of the day (in percent): ";
- cin >> humidity[ix];
- cout << endl;
- ++ix;
- }
- }
- while( ix != 0 );
- }
- }
- void mainmenu( int datatotal, int ix )
- {
- int choice;
- do
- {
- cout << endl;
- cout << "Please choose one of the following choices " << endl;
- cout << "(1) Display the data " << endl;
- cout << "(2) Display the maximun, minimum, and range of one field" << endl;
- cout << "(3) Display the largest difference between two consecutive" << endl;
- cout << "in one field" << endl;
- cout << "(4) Display a chart summarizing the distribution of the values" << endl;
- cout << "in one field" << endl;
- cout << "(5) Display the heat index for each day" << endl;
- cout << "(6) Stop Analyzing this collection of data" << endl;
- do
- {
- cout << "Enter a number from 1 to 6: ";
- cin >> choice;
- cout << endl;
- }
- while( choice > 6 || choice < 1 );
- if( choice >= 1 && choice <= 5 )
- {
- menuselection( choice, datatotal, ix );
- }
- else
- {
- cout << endl;
- cout << "Error" << endl;
- }
- }
- while( choice != 6 );
- }
- void menuselection ( int choice, int datatotal, int ix )
- {
- if( choice == 1 )
- {
- displaydata( datatotal, ix );
- }
- else if( choice == 2 )
- {
- cout << "test2" << endl;
- }
- else if( choice == 3 )
- {
- cout << "test3" << endl;
- }
- else if( choice == 4 )
- {
- cout << "test4" << endl;
- }
- else
- {
- cout << "test5" << endl;
- }
- }
- void displaydata( int datatotal, int ix )
- {
- int counter, gateway;
- char yorn;
- cout << "Display data" << endl;
- cout << endl;
- for ( ix = 0; ix <= datatotal; ++ix )
- {
- counter = 1;
- do
- {
- if( day[ix] != 0 )
- {
- cout << day[ix] << " "
- << htemp[ix] << " "
- << ltemp[ix] << " "
- << windspeed[ix] << " "
- << humidity[ix] << endl;
- cout << endl;
- ++counter;
- }
- else
- {
- }
- }
- while( counter <= 9 );
- cout << "Would you like to stream more data?" << endl;
- cout << "(y or n): ";
- cin >> yorn;
- if( yorn == 'y' )
- {
- }
- else
- {
- gateway = ix;
- ix = datatotal;
- }
- }
- ix = gateway;
- }
Add Comment
Please, Sign In to add comment