In: Computer Science
C++
in one program that ends with return 0} at the end
f
Write a program to calculate the salary paid to its
salespersons at Pohanka. The salary is calculated based on a
salesperson’s length of employment in years and employment category
(full-time employee or part-time employee). The salary calculation
rules are as following: 1) If an employee is a part-time employee
and worked here for less than 5 years, the salary consists of only
the commission amount; 2) If an employee is a part-time employee
and worked here for more than or equal to 5 years, the salary
consists of base salary of $2,500 and commission amount; 3) If an
employee is a full-time employee and worked here for less than 5
years, the salary consists of base salary of $5,000 and commission
amount; 4) If an employee is a full-time employee and worked here
for more than or equal to 5 years, the salary consists of base
salary of $10,000 and commission amount. The commission amount is
calculated using the following commission rates: Sales Amount
Commission Rate $0 to $15,000 10% $15,001 to $60,000 15% Over
$60,000 33% But there is a catch. The sales amount between $15,001
to $60,000 gets only 10% on the first $15,000 and 15% on the
remaining. The sales amount above $60,000 pays only 10% on the
first $15,000 and 15% on the next $45,000 and 33% on the remaining
amount
C++ Program:
#include <iostream>
using namespace std;
double commision(double sales_amount)
{
double first_15 = 15000, next_45 = 45000, rest, commision_amount = 0;
if (sales_amount > 60000)
{
rest = sales_amount - (first_15 + next_45);
first_15 = ( first_15 * 10 ) / 100;
next_45 = ( next_45 * 15) / 100;
rest = (rest * 33) / 100;
commision_amount = first_15 + next_45 + rest;
}
else if ((sales_amount >= 15001) && (sales_amount <= 60000))
{
rest = sales_amount - first_15;
first_15 = ( first_15 * 10 ) / 100;
rest = (rest * 15) / 100;
commision_amount = first_15 + rest;
}
else if ((sales_amount >= 0) && (sales_amount <= 15000))
{
sales_amount = (sales_amount * 10) / 100;
commision_amount = sales_amount;
}
return commision_amount;
}
int main()
{
cout<<"1. Part-Time Employee \n2. Full-Time Employee";
int type, years;
double sales_amount, base_salary = 0, salary = 0;
cout<<"\n\n-----------------------------------------";
cout<<"\nEnter Employee Type: ";
cin>>type;
cout<<"Enter Years of Employment: ";
cin>>years;
cout<<"Enter Your Sales Amount: ";
cin>>sales_amount;
cout<<"-----------------------------------------";
switch(type)
{
case 1:
if (years < 5)
{
salary = commision(sales_amount);
cout << "\n\n************** SALARY SLIP **************";
cout << "\n\nYour Salary: " << salary;
cout << "\n\n*****************************************";
}
else if (years >= 5)
{
base_salary = 2500;
salary = base_salary + commision(sales_amount);
cout << "\n\n************** SALARY SLIP **************";
cout << "\n\nYour Salary: " << salary;
cout << "\n\n*****************************************";
}
break;
case 2:
if (years < 5)
{
base_salary = 5000;
salary = base_salary + commision(sales_amount);
cout << "\n\n************** SALARY SLIP **************";
cout << "\n\nYour Salary: " << salary;
cout << "\n\n*****************************************";
}
else if (years >= 5)
{
base_salary = 10000;
salary = base_salary + commision(sales_amount);
cout << "\n\n************** SALARY SLIP **************";
cout << "\n\nYour Salary: " << salary;
cout << "\n\n*****************************************";
}
break;
default:
cout << "Wrong Entry of Type of Employement !!, Try Again !!";
}
return 0;
}
Output:
Thumbs Up Please !!!