i have an assignment due for my c++ class where we have to input from the keyboard the quantity and input from the keyboard the stock price.
so that it outputs as:
Stock Item Quantity Unit Price Total Value
----------------------------------------------
Television 5 368.00 1840.00
Video Recorder 8 268.00 2144.00
Camera 9 300.00 2700.00
DVD 10 468.00 4680.00
Hi Fi Stereo 13 2500.00 32500.00
Video CD 25 345.00 8625.00
----------------------------------------------
Gross Total: 52489.00
this is the code i have so far. i know i need to declare everything but i don't know how or where i should put it if any one has any advice that would be helpful. i hope i've given all the information you need.
#include<iostream.h> //is used so it will display output to the user and that input can be read from the keyboard
#include<iomanip.h> //is used so that the user can format input
using namespace std;
void getQuanity(int&,int);
void getStock(int, int&);
void gross(int[],int,int);
int main()
{
int item [6] = { Television, VideoRecorder, Camera, DVD, HiFiStereo, VideoCD };
int total = 0;
cout<<setiosflags(ios::fixed)<<setprecision(2); //sets the output to 2 decimal places
cout<<setiosflags(ios::fixed)<<setprecision(2);
cout<<setiosflags(ios::fixed)<<setprecision(2);
cout<<setw(15)<< "Item" //fomats the output
<<setw(11)<< "Quantity"
<<setw(13)<< "Unit Price"
<<setw(14)<< "Total Value"<<endl;
cout<<"============================================================="<<endl;
cout<<setw(15)<< "Television"
<<setw(11)<< qty1
<<setw(13)<< price1
<<setw(14)<< totalStockValue1<<endl;
cout<<setw(15)<< "Video Recorder"
<<setw(11)<< qty2
<<setw(13)<< price2
<<setw(14)<< totalStockValue2<<endl;
cout<<setw(15)<< "Camera"
<<setw(11)<< qty3
<<setw(13)<< price3
<<setw(14)<< totalStockValue3<<endl;
cout<<setw(15)<< "DVD"
<<setw(11)<< qty4
<<setw(13)<< price4
<<setw(14)<< totalStockValue4<<endl;
cout<<setw(15)<< "HiFi Stereo"
<<setw(11)<< qty5
<<setw(13)<< price5
<<setw(14)<< totalStockValue5<<endl;
cout<<setw(15)<< "Video CD"
<<setw(11)<< qty6
<<setw(13)<< price6
<<setw(14)<< totalStockValue6<<endl;
cout<<"============================================================="<<endl;
cout<<setw(45)<< "Gross Total: "
<<setw(4)<<gross<<totalGrossValue<<endl;
system("pause");
for(int k = 0; k < 6; k++)
{
input(qtyStock[k], stockPrice[k], k);
gross += computation(qtyStock[k], stockPrice[k], stockValue[k]);
}
for (int i = 0; i<SIZE; i++)
{
getNumber(item[i], i+1);
sum(item[i],total);
}
output (item, total, SIZE);
system("pause");
}
void getNumber(int &num, int numCount)
{
cout<<"Enter Number" << numCount<< ":";
cin>>num;
}
heading();
for(int m = 0; m < 6; m++)
{
output(qtyStock[m], stockPrice[m], stockValue[m], m);
}
outputGross(gross);
}