Use a few sentences to describe the problem given
below . Also, Identify the nouns and verbs used in the below
project descriptions. Identified nouns, list the ones
that are necessary to define variables in your program. For each
variable, specify its name, data type, and what information it is
used to store. Write the pseudo code algorithm (i.e. algorithm
steps) to solve this problem. (For the base salaries and commission
rates use constants instead to keep these values. Use the if else
statement and loop statement)
In the C++ code
Use COMMENT YOUR CODE and use meaningful variable names; and.
Conduct the following error checking of user input: - length of
employment must NOT be less than or equal to 0 - sales
amount must NOT be less than or equal to 0.
Create your testing plan and follow your testing plan to thoroughly
test all possible cases, which include all commission rates,
lengths of employment, and employment categories. Make sure to test
your error checking code. Keep all your testing data and testing
results so you can submit them.
Problem question 1, 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%
Write the program will receive a user’s input of the number of
salespersons from the keyboard. For each salesperson, your program
will
1) read in the salesperson’s first name, last name, the length of
employment in years, employment category, and the sale amount in
dollar from the keyboard;
2) calculate the appropriate commission and salary for this
salesperson; 3) display this salesperson’s first name, last name,
total commission, and total salary amount in a nice format.
Before your program exits, it should display the
average commission and the average salary amount for all the
employees.
#include <iostream>
using namespace std;
int main() {
int num_emp,totalCommision=0,totalsalary=0;
cout << "Enter number of employees"<<endl;
cin>>num_emp; //num_emp contains number of employees.
string fname[num_emp],lname[num_emp]; //contains list of first
names and last names of employees.
float
elength[num_emp],sale[num_emp],salary[num_emp],commision[num_emp];
char category[num_emp]; //Employement category F for full-time and
P for Part-time.
for(int i=0;i<num_emp;i++) //for each number of employees.
{
cout<<"Enter first name ";
cin>>fname[i];
cout<<"last name ";
cin>>lname[i];
cout<<"employment length in years ";
cin>>elength[i];
if(elength[i]<0)
{
cout<<"employment length should be greater than
0."<<endl;
exit(0);
}
cout<<"employment category : Press F for full-time and P for
Part-time ";
cin>>category[i];
cout<<"sale amount ";
cin>>sale[i];
if(sale[i]<0)
{
cout<<"sale should be greater than 0."<<endl;
exit(0);
}
}
for(int i=0;i<num_emp;i++)
{
if(sale[i]>=0 && sale[i]<=15000) // 0 < sale <
15000 : commision is 10% of sale.
commision[i]=0.1*sale[i];
else if(sale[i]>15000 && sale[i]<=60000) // 15001
< sale < 60000 : commision is 15% of sale.
commision[i]=0.15*sale[i];
else if(sale[i]>60000) // 60001 < sale : commision is 33% of
sale.
commision[i]=0.33*sale[i];
if(category[i]=='P' && elength[i]<5) // If employee is
part-time and worked for less than 5 years, then salary=commission
amount.
{
salary[i]=commision[i];
}
if(category[i]=='P' && elength[i]>=5) // If employee is
part-time and worked for less than 5 years, then salary=commission
amount+2500.
{
salary[i]=commision[i]+2500;
}
if(category[i]=='F' && elength[i]<5) // If employee
is part-time and worked for less than 5 years, then
salary=commission amount+5000.
{
salary[i]=commision[i]+5000;
}
if(category[i]=='F' && elength[i]>=5) // If employee is
part-time and worked for less than 5 years, then salary=commission
amount+10000.
{
salary[i]=commision[i]+10000;
}
totalsalary+=salary[i]; //totalsalary=sum of salary of each
employee.
totalCommision+=commision[i]; //totalcommision=sum of commision of
each employee.
}
cout<<"First Name\tLast Name\tTotal Commision\tTotal
salary\n"<<endl;
for(int i=0;i<num_emp;i++)
{
cout<<fname[i]<<"\t\t"<<lname[i]<<"\t\t"<<commision[i]<<"\t\t"<<salary[i]<<endl;
}
cout<<endl;
cout<<"Average
Commision:"<<(totalCommision/num_emp)<<endl; //Showing
avg. commission in the end.
cout<<"Average
Salary:"<<(totalsalary/num_emp)<<endl; //Showing avg.
salary in the end.
return 0;
}
Get Answers For Free
Most questions answered within 1 hours.