Question
Create a class named as CarSalesman in package named dealer.personnel, with the following properties and methods: int id String name double totalSales (for this specific
int id
String name
double totalSales (for this specific salesman)
double totalComission(for this specific salesman)
All the attributes mentioned above should be private members.
Methods:
1.) a default constructor that initialize id = 0, name = , totalSales = 0, and totalComission = 0;
2.) a constructor with two parameters (id, name) and set the appropriate properties, and set totalSales = 0, and totalComission = 0;
3.) a method named makeSale(double amount), you will update totalSales and totalComission here.
4.) a method named querySale (it returns totalSales)
5.) a method named queryCommission (it returns totalComission)
Create a class named as CarSalesmanManager in package dealer.personnelmanagement with the following properties and methods:
1.) int numOfSalesman
2.) an array that is used to hold a group of salesman
Methods:
1.) a default constructor that initializes an array with 10 salesman
2.) a constructor with a parameter specifying the maximum number of salesman this manager can hold;
3.) a method named getSalesman(id), which returns a Salesman object whose id is as specified, if no such salesman exists, return null.
4.) a method named addSalesman(id, name), which adds a new salesman with the id and name information into the system; make sure that you will NOT add the new salesman in if a salesman with the same id already exists.
Now create a class named as ManagerTest in the default package (do not specify the package) to test your implementation.
The commission can be calculated by the following formula:
1.) If the sales amount (per sale, not the total sales amount) is smaller than 1000, no commission.
2.) If the sales is from 1000 to 2000, the salesperson will earn 5% of the amount that is larger than 1000.
3.) If the sales is larger than 2000, the salesperson will earn 50 plus 10% of the amount that is larger than 2000.
For example, if a salesman sells an item for $700, he earns 0 commission.
If he sells an item for $1400, he will earn (1400 1000) * 5% = 20
If he sells an item for $4000, he will earn 50 + (4000 2000)*10% = 250
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