Question
c++ A company has sales reps that sell two different product lines. The sales amounts for each product are recorded, and commission is calculated based
c++
A company has sales reps that sell two different product lines. The sales amounts for each product are recorded, and commission is calculated based on the total sales. Commission is:
-5% of sales for sales < 4000
-7% of sales for 4000 to < 8000
-10% of sales for 8000 or above
Create a class called SalesRep with attributes (private data members) of:
-Salesrep name
-Product1 sales amount
-Product2 sales amount
Include these methods (note that you may or may not use all of them in your app)
-Create a default and parameterized constructor
-Create set / get methods for name
-Create get methods to calculate and return total sales, commission
Create your app class, SalesRepTest. In main, you will create an arrayList (or static array, your choice) of these SalesRep objects. (If you use a static array, make it large enough to hold 20 salesreps, but there may be less than 20 entered). Implement the following menu options:
1 Add sales rep prompt for name and the two sales amounts, add to arrayList or array
2 - Print sales report prints the name, total sales, and commission for all reps entered into the system in the format shown below on sample output. Also calculate and print the total sales and commission of all reps (note totals calculated in app, not in class).
3 - Print Diamond Club Prints the name and total sales of all reps with $10000 or more in total sales
4 - Exit
You should validate the menu choice with a loop. You can assume all sales rep data is valid
SAMPLE OUTPUT: (must caculate total sales and commision on our own which is why answer is not given)
Sales Reporting System 1 Add rep 2 - Print sales report 3 - Print Diamond Club 4 - Exit Enter your choice: 5 Invalid choice, re-enter: 1 Enter name: Captain Kirk Enter product 1 sales: 8500 Enter product 2 sales: 2650 (show menu) Enter your choice: 1 Enter name: Bruce Wayne Enter product 1 sales: 4880 Enter product 2 sales: 3120 (show menu) Enter your choice: 2 Sales Report Salesperson Total Sales Commission Captain Kirk $ xxxxx.xx $ xxxxx.xx Bruce Wayne $ xxxxx.xx $ xxxxx.xx Total $ xxxxx.xx $ xxxxx.xx (menu) Enter your choice: 1 Enter name: Harry Potter Enter product 1 sales: 1500 Enter product 2 sales: 850 (menu) Enter your choice: 1 Enter name: Peter Parker Enter product 1 sales: 9800 Enter product 2 sales: 5100 (menu) Enter your choice: 1 Enter name: Clark Kent Enter product 1 sales: 2750 Enter product 2 sales: 1250 (menu) Enter your choice: 2 Sales Report Salesperson Total Sales Commission Captain Kirk $ xxxxx.xx $ xxxxx.xx Bruce Wayne $ xxxxx.xx $ xxxxx.xx Harry Potter $ xxxxx.xx $ xxxxx.xx Peter Parker $ xxxxx.xx $ xxxxx.xx Clark Kent $ xxxxx.xx $ xxxxx.xx Total $ xxxxx.xx $ xxxxx.xx (menu) Enter your choice: 3 Diamond Club Qualified Name Total Sales (name(s)) $ xxxxx.xx
Sales Reporting System 1 - Print sales report 2 - Lookup sales rep 3 - Print Diamond Club 4 - Exit Enter your choice: 4 Goodbye!
#include
#include
#include
using namespace std;
class SalesRep //declared the class
{
private:
string name;
double salesamt1;
double salesamt2;
public:
SalesRep () //default constructor
{
name = "Bruce";
salesamt1 = 1234.67;
salesamt2 = 6789.89;
}
SalesRep (string Name, double Salesamt1, double Salesamt2 ) //parametized constructor
{
name = Name;
salesamt1 = Salesamt1;
salesamt2 = Salesamt2;
}
void setname (string sname);
string getname ();
void setprd1 (double ssalesamt1);
double getprd1 ();
void setprd2 (double ssalesamt2);
double getprd2 ();
double getsales ();
double getcommisions ();
float calcPay (float commission);
};
void
SalesRep::setname (string sname) //setting name
{
name = sname;
}
string
SalesRep::getname ()
{ //returning name
return name;
}
void //setting amount sales
SalesRep::setprd1 (double ssalesamt1)
{
salesamt1 = ssalesamt1;
}
double
SalesRep::getprd1 ()
{
return salesamt1; //returning the sales amt for product1
}
void
SalesRep::setprd2 (double ssalesamt2)
{ //setting the amount sales for product 2
salesamt2 = ssalesamt2;
}
double //returning the amount of sales for products2
SalesRep::getprd2 ()
{
return salesamt2;
}
double
SalesRep::getsales ()
{
int salesAmt;
//the get sales function
cout << "Enter a monthly sales amount: ";
cin >> salesAmt;
return salesAmt;
}
double
SalesRep::getcommisions ()
{
//commision being calculated by %
float commission;
if (salesamt1 <= 8000)
{
commission = .10 * salesamt1;
}
else if (salesamt1 >= 4000)
{
commission = .07 * salesamt1;
}
else if (salesamt1 < 4000)
{
commission = .10 * salesamt1;
}
else
{
commission = 0 * salesamt1;
}
return commission;
}
float
SalesRep::calcPay (float commission)
{ //total pay
float totalPay;
totalPay= salesamt1*commission;
return totalPay;
}
int
main ()
{
SalesRep ob;
ob.getsales();
ob.getcommisions();
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started