/*
* Pass6
*/
/* People get paid a base salary, plus a percentage of all sales over the base sales amount.
1) Read 3 digit salesman ID number, a float base salary and sales amount for each category.
2) Using a function, compute the commission earned in each category.
3) Print the ID number and base salary.
4) For each category, print description, sales amount, and commission amount.
5) Print total commission paid to the employee and total paid.
6) Continue looping until -999 is inputted for Salesman Number.
*/
#include <iostream>
#include <iomanip>
using namespace std;
/* Universal Floats */
float totalPcCom, totalMemCom, totalZipCom, totalPrintCom, baseSalary, pcSales, memCardSales, zipDriveSales, printerSales, totalCommission;
/* Function Prototype */
double calcComm(pcSales, memCardSales, zipDriveSales, printerSales);
int main ()
{
/* Everything has to be in a loop!!!! */
int salesID;
do
{
/* Output for 3 digit salesman ID number, float base salary and sales amount for each category. */
cout << "Please Enter Salesman ID number or -999 to terminate: " << endl;
cin >> salesID;
cout << "Please Enter Base Salary: " << endl;
cin >> baseSalary;
cout << "Please Enter Personal Computer Sales: " << endl;
cin >> pcSales;
cout << "Please Enter Memory Card Sales: " << endl;
cin >> memCardSales;
cout << "Please Enter Zip Drive Sales: " << endl;
cin >> zipDriveSales;
cout << "Please Enter Printer Sales: " << endl;
cin >> printerSales;
/* Function and Computation Time!!! */
totalCommission = calcComm (pcSales, memCardSales, zipDriveSales, printerSales);
/* Displaying the information for the current salesman */
cout << "Saleman ID # " << salesID << endl;
cout << "Base Salary: " << baseSalary << endl;
cout << "Total PC Commission: " << totalPcCom << endl;
}
/* Checking again if id!=-999 */
while (salesID!=-999);
return 0;
}
double calcCommission (baseSalary, pcSales, memCardSales, zipDriveSales, printerSales)
{
/* Check and see if salesman gets commission from PCs
If so, commission is calculated. If not, commission
is left at zero. */
if (pcSales>=4000)
return totalPcCom = (pcSales - 4000) * .10;
else
return totalPcCom = 0;
/* Check and see about other commissions */
if (memCardSales>=1000)
return totalMemCom = (memCardSales - 1000) * .05;
else
return totalMemCom = 0;
if (zipDriveSales>=800)
return totalZipCom = (zipDriveSales - 800) * .04;
else
return totalZipCom = 0;
if (printerSales>=2000)
return totalPrintCom = (printerSales - 2000) * .08;
else
return totalPrintCom = 0;
}