rendered paste body#include <iostream>#include "hydro.h"#include "FlowList.h"#include <stdlib.h>#include <fstream>using namespace std;int main(void){ FlowList x; int numRecords; displayHeader(); numRecords = readData(x); while(1) { switch(menu()) { case 1: display(x); break; case 2: break; } }}void clearScreen(void){ #ifndef UNIX system("clear") #endif}void pressEnter(){ cout<<"<<<Press Return to Continue>>>"<<endl; getchar();}void displayHeader(){ clearScreen(); cout<<"\nHEF Hydropower Studies - Fall 2007"<<endl; cout<<"Program: Flow Studies"<<endl; cout<<"Version: 1.0"<<endl; cout<<"Lab Section: B01"<<endl; cout<<"Produced By: Brian Hoang"<<endl; cout<<endl; pressEnter();}int readData(FlowList* x){ ifstream inObj; ListItem input_struct; inObj.open("flow.dat"); if(inObj == NULL) { cout<<"There was an error in opening the file."<<endl; exit(1); } while(!inObj.eof()) { inObj>>input_struct.year>>input_struct.flow; x.insert(input_struct); } return x.count();}int menu(){ int choice = -1; clearScreen(); cout<<"Please select one of the following operations"<<endl; cout<<"1. Display data"<<endl; cout<<"2. Display statistics"<<endl; cout<<"3. Add data"<<endl; cout<<"4. Save data into the file"<<endl; cout<<"5. Remove data"<<endl; cout<<"6. Remove data"<<endl; cout<<"Enter your choice (1, 2, 3, ... or 6)"<<endl; cin>>choice; cleanStandardInputStream(); return choice;}void display(FlowList* x){ x.display(); pressEnter();}void addData(FlowList* x){ ListItem input_struct; cout<<"Please enter a year:"<<endl; cin>>input_struct.year; cout<<endl; cout<<"Please enter the flow of that year:"<<endl; cin>>input_struct.flow; x.insert(input_struct); numRecords = x.count(); pressEnter();}void removeData(FlowList* x){ ListItem remove_struct; cout<<"Please enter the year to be removed:"<<endl; cin>>remove_struct.year; x.remove(remove_struct); numRecords = x.count(); pressEnter(); return;}void saveData(FlowList* x){ x.export(); pressEnter();}void statistics(FlowList* x){ cout<<"The average flow is "<<x.average()<<endl; cout<<"The median flow is "<<x.median()<<endl; pressEnter();}void cleanStandardInputStream (void){ int leftover; do { leftover = fgetc(stdin); } while (leftover !='\n' && leftover != EOF);}