Question
Creating classes using inheritance At Acme Sales, some sale reps are paid commission on the number of pieces sold, while others are paid a commission
Creating classes using inheritance
At Acme Sales, some sale reps are paid commission on the number of pieces sold, while others are paid a commission based on a percentage of sales. Write a C++ program that calculates commission for different types of sales reps. You are required to use inheritance.
Create a base class called Worker, which has the following attributes which are common:
Name
Base pay
You should use protected so that derived classes can access these values (particularly base pay).
Create appropriate constructors, set/get functions
You will need a pure virtual functon to calculate and return the commission
You will need a pure virtual function to print a customized check
Derive the class PieceRep which is a specific type of Worker that is paid commission based on the number of pieces sold. Include the following additional data in this class:
Number of pieces sold
Commission is paid as follows:
Pieces sold commission
< 200 $0.75 per piece
200 999 $1.25 per piece
1000+ $1.75 per piece
Create appropriate functions
Derive the class SalesRep which is a specific type of Worker that is paid commission based on the amount of sales. Include the following additional data in this class:
Monthly sales
Commisssion is paid as follows:
Sales Commission
< 5000 15% of sales
5000 9999.99 18% of sales
10,000+ 20% of sales
Create appropriate functions
The application will create a vector of base class pointers to store data about pieceworkers and salesreps in a single "container". You should display a menu as shown below. You should validate the menu choice, but NO DATA VALIDATION NEEDED for class data. Remember that all calculations are done in the class. Outputs are printed in main or "app" functions. See sample output below.
1 - Add employee 2 - Payroll report 3 - Print all checks 4 - Quit Your choice: 1 Enter p for piece rep, s for sales rep: p Enter name: (you choose a name) Enter base pay: 500 How many pieces sold? 200 1 - Add employee 2 - Payroll report 3 - Print all checks 4 - Quit Your choice: 1 Enter p for piece rep, s for sales rep: s Enter name: (your choice) Enter base pay: 500 Monthly sales? 4000 1 - Add employee 2 - Payroll report 3 - Print all checks 4 - Quit Your choice: 2
Payroll Report Name Base Commission Total (name) $ 500.00 $ xxx.xx $ xxx.xx (name) $ 500.00 $ xxx.xx $ xxx.xx Total payroll $ xxxxxxx.xx 1 - Add employee 2 - Payroll report 3 - Print all checks 4 - Quit Your choice: 3 Employee type: PieceRep Name: (your name) Pieces sold: 200 Commission is $x.xx per piece Base pay: $ 500.00 Commission: $ xxx.xx Total pay: $ xxx.xx Employee type: SalesRep Name: (your name) Monthly sales: 4000.00 Commission is xx % of sales Base pay: $ 500.00 Commission: $ xxx.xx Total pay: $ xxx.xx
1 - Add employee 2 - Payroll report 3 - Print all checks 4 - Quit Your choice: 4 Goodbye! Programmed by your name
Test Data: Use the following test data (make up the names). Make sure the answers are correct!
Pieceworker, base $400, 200 pieces
Pieceworker, base $500, 1200 pieces
Pieceworker, base $300, 100 pieces
SalesRep, base $400, $5000 sales
SalesRep, base $500, $11000 sales
SalesRep, base $300, $4500 sales
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