////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// // // Your Name : Joe Program (joe@andrew.cmu.edu) // Course : MSCF - OOP I // Project # : One // // Description : // // Place description here... // // Last Modified : // // Known Bugs : // ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// #include //Standard C++ I/O: cin/cout >>/<< #include #include #include #include using namespace std; const int MAXFILENAME = 180; struct data{ string date; double max, min, close; long volume; }; // function prototypes void OpenFileForReading(char [], ifstream&); void OpenFileForWriting(char [], ofstream &); void IgnoreWordsTill(ifstream &,string); int read_data(data [],ifstream &); void histogram(const data [],int); void average(const data [],int); void stdDeviation(const data [],int); void showDates(const data [],int); char menu(); int main() { ifstream infile; OpenFileForReading("Enter input file name : ", infile); IgnoreWordsTill(infile,"VOLUME"); data list[260]; // holds data up to a year of data excluding weekends int size = read_data(list, infile) ; // reads data from infile into the array for (; ;) { int flag = 0; char ch = menu(); // display the menu and returns the choice switch (ch) { case 'h' : case 'H' : histogram(list,size); break; // see below for function descriptions case 'a' : case 'A' : average(list,size); break; case 's' : case 'S' : stdDeviation(list,size); break; case 'd' : case 'D' : showDates(list,size);break; case 'q' : case 'Q' : flag = 1; break; default : ; } if (flag) break; } cout << "That's all Folks!" << endl; return 0; } // The following function skips all words from the file f until // the word s is encountered. void IgnoreWordsTill(ifstream &f,string s){ string temp; do { f>>temp; } while (temp != s); } // OpenFile Utilities void OpenFileForReading(char message[], ifstream& infile) { char filename[MAXFILENAME]; do { cout << message; cin.getline(filename,MAXFILENAME); infile.open(filename, ios::in); if (infile.fail()) { cout << endl << "INPUT FILE COULD NOT BE OPENED!" << endl; infile.clear(); } } while (!infile.is_open()); } void OpenFileForWriting(char message[],ofstream &outfile) { char filename[MAXFILENAME]; do { cout << message ; cin.getline(filename, MAXFILENAME); outfile.open(filename, ios::out | ios::trunc); if (outfile.fail()) { cout << "\nIOUTPUT FILE COULD NOT BE OPEN!" << endl; outfile.clear(); } } while (!outfile.is_open()); } // function defintions //////////////// MENU //////////////////////////////////// // This function will display the main menu of the program // Users select from Histogram, average(mean), StdDeviation // ,showDates or Quit ///////////////////////////////////////////////////////////// char menu(){ return 'q';} //////////////// HISTOGRAM //////////////////////////////////// // This function will display the histogram of the data. // USer inputs the number of intervals and program display // data ranges and frequencies ///////////////////////////////////////////////////////////// void histogram(const data A[], int size){}; //////////////// AVERAGE //////////////////////////////////// // This function display the mean of Max, min, close price and // volume based on user choice ///////////////////////////////////////////////////////////// void average(const data A[], int size){}; //////////////// STANDARD DEVIATION//////////////////////////////////// // This function display the Standard deviation of Max, min, close // price and volume based on user choice ///////////////////////////////////////////////////////////// void stdDeviation(const data A[], int size){}; //////////////// SHOW DATES //////////////////////////////////// // This function display all the dates where the closing stock // price was between given inputs ///////////////////////////////////////////////////////////// void showDates(const data A[], int size){}; //////////////// READ DATA //////////////////////////////////// // This function reads the financial data from file to the array // of structures. ///////////////////////////////////////////////////////////// int read_data(data A[],ifstream &f){return 1;};