In: Computer Science
In each regional branch of Marc-Lu sales company, every salesclerk has a monthly base salary. The salesclerk also takes a bonus at the end of each month based on the following criteria: If the salesclerk has been with the company for three or less years, the bonus is $100 for each year that he or she has worked there. If the salesperson has been with the company for more than three years and less or five years, the bonus is $200 for each year that he or she has worked there otherwise the bonus is $ 300. The salesclerk can also earn an extra bonus as follows: If the total sale made by the salesclerk for the month is more than $ 5,000 but less than $10,000 he or she receives a 3% commission on the sale. If the total sale made by the salesclerk for the month is at least $ 10,000 he or she receives a 6% commission on the sale.
a) Design an algorithm that calculates the monthly payment of a salesclerk at given regional branch.
b) List all the variables required to write this program.
c) Use the algorithm in (a) to write a complete C++ program to calculate monthly payment of a salesclerk at a given regional branch.
a) Design an algorithm that calculates the monthly payment of a salesclerk at given regional branch.
1. Begin
2. Initialize a value to basesalary.
3. Read name, years, sales
4. If years <3 Then
5. Compute bonus=100*years
6. Else If years>=3 and years<=5
7. Compute bonus=200*years
8. Else
9. Compute bonus=300*years
10. End If
11. If sales<=5000
12. Compute comm=0.0;
13. Else If sales>5000 and sales<10000
14. Compute comm=sales*0.03
15. Else
16. Compute comm=sales*0.06;
17. End If
18. Compute salary=basesalary+comm+bonus
19. Print name,basesalary,bonus,comm,salary
20. End
b) List all the variables required to write this program.
name, years, sales, bonus, basesalary, comm, salary
c) Use the algorithm in (a) to write a complete C++ program to calculate monthly payment of a salesclerk at a given regional branch.
C++ program pasted below.
#include <iostream>
using namespace std;
int main()
{ char name[20];
int years,sales,bonus;
//initialize monthly base salary to 3000
float basesalary=3000,comm,salary;
cout<<"Enter the name of Employee:";
cin>>name;
cout<<"Enter years of experience with the company:";
cin>>years;
cout<<"Enter the amount of sales:";
cin>>sales;
if(years<3)
bonus=100*years;
else if(years>=3 && years<=5)
bonus=200*years;
else
bonus=300*years;
if(sales<=5000)
comm=0.0;
else if(sales>5000 && sales<10000)
comm=sales*0.03;
else
comm=sales*0.06;
salary=basesalary+comm+bonus;
cout<<"Name:"<<name<<endl;
cout<<"Base salary:"<<basesalary<<endl;
cout<<"Bonus:"<<bonus<<endl;
cout<<"Commission:"<<comm<<endl;
cout<<"Net Salary:"<<salary<<endl;
return 0;
}
Output Screen