Hello people, i am Chris from Jamaica W.I. and i have been having a problem with write vector and stack programs (but mostly vectors). Anyway, the program i am writing involves the whole pushing and popping theory. I have that in check. My problem is that i dont kno how to set the width and set precision between the fields such as ID No#, Date, Sold ..etc.. and output the information below each field in format that is displayed below. If someone could be so kind as the help me out. That would be great. At least illustrate how i would go at it in vector and stack.
Write the vector/stack program. For the following data:
The program should output looking like this---->
ID No# Date Sold Returned Brought
------ ------ -------- ------------- -----------
285 1/10/05 125 34 50
341 2/10/05 300 52 0
467 3/12/05 50 70 200
589 1/11/05 75 10 55
P.S. This what i have done so far but apparently it is crap.
int main()
{
int IDnum[4] = {285, 341, 467, 589};
vector <int> v1(IDnum,IDnum +15);
vector <int> :: iterator iter = v1.begin();
int Date;
int Sold;
int Returned;
int Brought;
cout << left << setw( 10 ) << "ID No#" << setw( 10 )
<< "Date"<< setw(10) << "Sold" << setw( 10 ) << "Returned"<< setw(10) << "Brought" << endl << fixed << showpoint;
void outputLine( int ID, int Date, int Sold, int Returned, int Brought );
{
cout << left << setw( 10 ) << IDnum << setw( 13 ) << Date
<< setw( 7 ) << setprecision( 2 ) << right << Sold<< setw(10) << Returned << setw(10) << Brought
<< endl;
} // end function outputLine
system("pause");
return 0;
}