C++ stock help

Hey guys,
I'm new to C++ and I was told to do a project to maintain my scholarship in school for another year.
They're dumped this on me and I was watching 'Bucky' on YouTube to learn C++
He helped... not that much though.
I need to submit this in a week to maintain my scholarship. Please help?
Here is the gist of the question.

I need to create my own vector. I have an excel document from which information would be read: the document looks like this;

Course Of Sales
Time Price ($) Volume Value ($) Condition
10/10/2013 16:57 5.81 5000 29050 LT XT
10/10/2013 16:48 5.81 62728 364449.68 SX XT
10/10/2013 16:10 0 0 0

I figured I needed the following classes:
1 - Date class
2 - Time class
3 - Stock class
4 - Vector class

I don't know where to start, how to start. I'm getting the jitters.
Any help or guidance? That would be great. Really.
I have a week to do this... Please.
1 - Date class
2 - Time class
There are datetime handling facilities in standard library.

I have an excel document from which information would be read
It is a really broad definition. What kind of table file is is? I hope it is CSV, because if it is XLS, then you will not be able to parse it, seeing as you struggle with basics.

You did not tell actual information:
Why do you need to create own vector?
What your program should do?
What do you have problem with?

Start with clear understanding what you should do. Plan what your program should have and how it should look. Write down classes and their relations, how your program is going to be structured. Then turn on your PC and start coding.
Yes, it is a csv file so I know it can be separated by a comma.
So I need to build an Object oriented solution.

I have four options to create in my menu.
1. Find the highest share price and start time of the highest share price during the day.
2. Find the lowest share price and start time of the lowest share price during the day.
3. Output the answers in a text file.
4. Quit program.

A vector class needs to be used which is my own It is a dynamic array encapsulated in a class. It can access the private array through the public attributes. I cannot use STL structures.

I have an excel file (course_of_sales.csv) which has

Time and date in one cell, the volume of shares, the price of the shares, the value of the shares and the condition of the shares which is to be ignored.

I don't know how to split the time and date from one cell into two different classes.
How do I use getline to get the csv file and split on cell?
I need my program to run a min and max function (so I think) since I need to find highest and lowest share.

Thanks for the reply, btw :)
I don't know how to split the time and date from one cell into two different classes.
DO you really need that? Time point is perfectly represented by one class. Something like tm from C library will suffice.
You can separate CSV file into lines and then into fields like that:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
std::ifstream in("Sales.csv");
std::string temp;
std::istringstream line; 
line.exceptions(std::ios::fail);
std::tm datetime; //You should use your class members
double price, value; //Instead of these
while(std::getline(in, temp)) {
    line.str(temp);
    std::getline(line, temp, ','); //date
    std::sscanf(temp.c_str(), "%d/%d/%d", &datetime.tm_mon, &datetime.tm_mday, &datetime.tm_year); //Or just parse it as a stream too
    std::getline(line, temp, ','); //time
    std::sscanf(temp.c_str(), "%d:%d", &datetime.tm_hour, &datetime.tm_min, );
    std::getline(line, temp, ','); //price
    price = std::stod(temp);
    std::getline(line, temp, ','); //value
    value= std::stod(temp);
}
I am copying my answers here.
My file works perfectly, I just have an issue with my output file.
The csv output file is all weird. The first two lines are garbage.

Here is the third output,

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
else if (option == '3')
		{
			cout << "Option 3: Output the arranged data to 'Output.csv'" << '\n' << endl;
			ofstream ofile( "output.csv" );
			ofile << "Date" << ','<< "Time" << ',' << "Price" << ',' << "Volume" << ',' << "Value" << ',' <<'\n';
			int index2 = vector.GetVectorSize()-1;
			double SumValue=0;
			int SumVolume=0;
			/*!Reading the vector from end, because values are saved in decending order and I want them to be printed in acending order*/
			for (int index = vector.GetVectorSize(); index > 0 ; index--)
			{
				if (vector[index2].GetTime().GetShare().GetPrice() == vector[index].GetTime().GetShare().GetPrice())
				{
					SumValue=+vector[index].GetTime().GetShare().GetValue();
					SumVolume=+vector[index].GetTime().GetShare().GetVolume();
					index2--;
				}
				else if (vector[index2].GetTime().GetShare().GetPrice() != vector[index].GetTime().GetShare().GetPrice())
				{
					SumValue=+vector[index].GetTime().GetShare().GetValue();
					SumVolume=+vector[index].GetTime().GetShare().GetVolume();
					ofile <<vector[index].GetDay()<< "/" <<vector[index].GetMonth()<< "/" <<vector[index].GetYear()<<","<<
						vector[index].GetTime().GetHour()<<":"<<vector[index].GetTime().GetMinute()<<":" <<
						vector[index].GetTime().GetSecond() << " " << 
						vector[index].GetTime().GetPeriod() <<","<<
						vector[index].GetTime().GetShare().GetPrice()<<","<<
						vector[index].GetTime().GetShare().GetVolume()<<","<<
						vector[index].GetTime().GetShare().GetValue()<<"\n";
					index2--;
					SumValue=0;
					SumVolume=0;
				}				
			}
			///close output file
			ofile.close();
		}
Here is my vector file, just in case you need it.

Vector.h
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#ifndef VECTOR_H
#define VECTOR_H
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

///Templatizing the vector created
template <class DataType>
class Vector
{
private:
    ///Current size of the vector
	int CurrentSize;
	///Maximum size of vector
	int MaxSize;
	DataType* VecLocation;
	///function to allocate more space
	void AllocateSpace();

public:
    ///Get the size of vector
	int GetVectorSize();
	///Push new element in the vector
	void PushBack (const DataType& );
	///pop element out from vector
	void PopBack();
	DataType& operator[](int Location);
	friend istream & operator >> (istream & input, Vector & R);

	DataType ReturnElement(int Location);
	Vector(int MaxElements);
	///constructor
	Vector();
	///deep copy constructor
	Vector(const Vector&);
	///destructor
	~Vector();
  };

template<class DataType>
inline Vector<DataType>::Vector()
{
    ///initial maximum size
	MaxSize= 16;
	VecLocation= new DataType[MaxSize];
	///initial current size
	CurrentSize= 0;
}

template<class DataType>
inline Vector<DataType>::Vector(int MaxElements)
{
	MaxSize	= MaxElements;
	VecLocation = new DataType[MaxSize];
	CurrentSize	= 0;
}

template <class DataType>
inline Vector<DataType>::Vector(const Vector& vec)
{
	MaxSize = vec.MaxSize;
	CurrentSize = vec.CurrentSize;
	VecLocation = new DataType[MaxSize];
	for (int i=0; i <vec.MaxSize; i++)
	{
		VecLocation[i]=vec.VecLocation[i];
	}
}

template<class DataType>
inline Vector<DataType>::~Vector()
{
	delete[] VecLocation;
}

template<class DataType>
inline void Vector<DataType>::PushBack(const DataType& input)
{
	if ( (CurrentSize+1) > MaxSize )
	{
		AllocateSpace();
	}
	VecLocation[CurrentSize]=input;
	CurrentSize++;
}

template<class DataType>
inline DataType Vector<DataType>::ReturnElement(int Location)
{
	if (Location<CurrentSize)
	{
		return *VecLocation[Location];
	}
}

template<class DataType>
///Move to a temporary location
inline void Vector<DataType>::AllocateSpace()
{
	MaxSize	= CurrentSize*2;
	DataType* Temp = new DataType[MaxSize];
	for ( int j=0; j<CurrentSize; j++)
	{
		Temp[j]=VecLocation[j];
	}
	delete[] VecLocation;
	VecLocation=Temp;
}

template<class DataType>
inline int Vector<DataType>::GetVectorSize()
{
	return CurrentSize;
}

template <class DataType>
inline DataType& Vector<DataType>::operator[] (int Location)
{
	return VecLocation[Location];
}

template <class DataType>
///Relocate from Temp to VecLocation
inline void Vector<DataType>::PopBack()
{
	MaxSize = CurrentSize*2 ;
	DataType* Temp = new DataType[MaxSize];
	for ( int k=0; k<(CurrentSize-1); k++)
	{
		Temp[k]=VecLocation[k];
	}
	delete[] VecLocation;
	VecLocation=Temp;
}

#endif 
Thank you all the members in this thread. I got good understanding and context what I needed for a technical interview.
Thanks guys, I got it working anyway :)
Topic archived. No new replies allowed.