here is the question and what I have so far.(Stock Market) Write a program to he
ID: 3659795 • Letter: H
Question
here is the question and what I have so far.(Stock Market) Write a program to help a local stock trading company automate its systems. The company invests only in the stock market. At the end of each trading day, the company would like to generate and post the listing of its stocks so that investors can see how their holdings performed that day. We assume that the company invests in, say, 10 different stocks. The desired output is to produce two listings, one sorted by stock symbol and another sorted by percent gain from highest to lowest. The input data is provided in a file in the following format: symbol openingPrice closingPrice todayHigh todayLow prevClose volume For example, the sample data is: MSMT 112.50 115.75 116.50 111.75 113.50 6723823 CBA 67.50 75.50 78.75 67.50 65.75 378233 . . . The first line indicates that the stock symbol is MSMT, todayExplanation / Answer
#ifndef H_listType #define H_listType #include #include #include using namespace std; template class listType { //class template to create an array and perform various functions public: bool isEmpty() const; bool isFull() const; int getLength() const; int getMaxSize() const; void sort(); void print() const; void insertAt(const elemType& item, int position); listType(int listSize = 50); ~listType(); protected: int maxSize; int length; elemType *list; }; template bool listType::isEmpty() const { //function to check if array is empty return (length == 0); } template bool listType::isFull() const { //function to check if array is full return (length == maxSize); } template int listType::getLength() const { //function to get length return length; } template int listType::getMaxSize() const { //function to get maxSize return maxSize; } template listType::listType(int listSize) { //default constructor maxSize = listSize; length = 0; list = new elemType[maxSize]; } template listType::~listType() { //destructor delete [] list; } template void listType::sort() { //sort function int i, j; int min; elemType temp; for(i = 0; i > arrayOfStruct[counter].low infile >> arrayOfStruct[counter].previousClose infile >> arrayOfStruct[counter].percentGain infile >> arrayOfStruct[counter].volume; } void sortTndices () { int i = 0; for (i = 0; i < 50; i++) if (myArray[i]Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.