Basically, I've got this coursework that's due in for this Thursday.
It's pretty much finished, but I can't seem to get this last bit working.
Everything is fine except for the commission, which SHOULD work, provided I get this "personalTotal" double working. I know that I need to some how link it to the length of my vector/array thing, but I haven't got the faintest idea how to do that.
It needs to be incorporated with the "for" loop above it which has all the "char (156)" bits in it.
#include "stdafx.h"
#include <vector>
#include <iostream>
usingnamespace std;
int main()
{
int noOfSalesPeople = 0, temp = 0;
vector <double> productA; vector <double> productB; vector <double> productC; vector <double> totalProduct;
double companyTotal = 0;
double priceA = 50, priceB = 75, priceC = 150;
double com1, com2, com3;
//double personalTotal;
//double total = com1 + com2 + com3;
cout << " " << endl;
cout << "Please enter the number of sales people: ";
cin >> noOfSalesPeople;
cout << " " << endl;
cout << " " << endl;
for( int i = 0; i < noOfSalesPeople; i++ )
{
cout << "Sales Person " << i << ":" << endl;
cout << endl << "Amount of product A sold this month: "; cin >> temp; productA.push_back ( temp*priceA );
cout << endl << "Amount of product B sold this month: " ; cin >> temp; productB.push_back ( temp*priceB );
cout << endl << "Amount of product C sold this month: "; cin >> temp; productC.push_back ( temp*priceC );
totalProduct.push_back( productA [i] + productB [i] + productC [i] );
companyTotal += totalProduct [i];
cout << " " << endl;
cout << " " << endl;
}
for ( int i = 0; i < noOfSalesPeople; i++ )
{
cout << " " << endl;
cout << "Sales Person " << i << ":" << endl;
cout << " " << endl;
cout << "This months total sales for product A: " << endl;
cout << char(156) << productA [i] << endl;
cout << " " << endl;
cout << "This months total sales for product B: " << endl;
cout << char(156) << productB [i] << endl;
cout << " " << endl;
cout << "This months total sales for product C: " << endl;
cout << char(156) << productC [i] << endl;
cout << " " << endl;
cout << "This months total sales for this sales person: " << endl;
cout << char(156) << totalProduct [i] << endl;
cout << " " << endl;
cout << " " << endl;
//personalTotal [i] = productA [i] * 50 + productB [i] * 75 + productC [i] * 150;
}
//THIS BIT HERE:
// COMMISSION!!!!!
//if (personalTotal <= 1000)
//{
// com1 = personalTotal*0.05;
//}
//else if (personalTotal - 1000 <= 10000)
//{
// com2 = (personalTotal - 1000)* 0.03;
// }
//
// else if (personalTotal - 10000 <= 100000)
// {
// com3 = (personalTotal - 10000) * 0.01;
//
// }
So, basically, any help I could get with this would be greatly appreciated. I managed to do the rest of this piece by myself, and I haven't had any major problems so far.
writetonsharma - personalTotal is declared at the top of the code. But I dropped it into note form so I could highlight the areas I'm having trouble with.
I know what you mean by the {}
But you you know how I could get the commission to work for each person, the same as this "for loop" below?: