Here the question.
A company owned by First Avenue has a salary system based on position level. Employee salary is being paid on a weekly basis. The company has 30 employees, which comprises of a manager (fixed salary), cooks (salary on hourly basis), salesperson (fixed salary and sales commission). Below shows the details of salary payment for each position level.
1) Position level : Manager
Salary paid per week : Fixed salary
2) Position level : Cooks
Salary paid per week : First 30 hours - fixed rate every hour. The next following hours, overtime rate at 1.5% of the fixed rate hourly
3) Position level : Salesperson
Salary paid per week : $300 plus commission 8.5% of the total sales per week.
Calculate the amount of salary received for each employee based on their position level in the company.
Given is the input, output, solution/formula, and constraint for the above problem :
Inputs:
*fixed input:
- fixed salary for a manager
- fixed rate for cooks
- basic salary for salesperson
- commission rate
*user’s input:
- position category
- total working hours for cooks
- total sales for salesperson
Outputs:
- position category
- total income
Solution/Formula:
1) Income for a manager is fixed
2) Income for cooks is calculated by multiply total working hours with fixed rate:
2.1 if total working hours less than or equal 30 hours,
Total income = total working hours * fixed rate
2.2 if total working hours more than 30 hours
Total income = 30 * fixed rate + total working hours – 30 * 1.5 * fixed rate
3) Total income for a salesperson = $300 + commission rate * total sales per
week
Constraints:
- total working hours can not exceed than 168 hours
- total working hours must be entered for cooks
- total sales must be entered for salesperson
so, have to write a C++ program to calculate.
here is the code that i have done :
#include <iostream>
using namespace std;
int main(){
double managersalary, cooksfixedrate, salespersonsalary, commissionrate, cookstotalworkinghours, salespersontotalsales, totalincome;
char position, manager, cooks, salesperson;
managersalary = 1000.00;
cooksfixedrate = 15.00;
salespersonsalary = 300.00;
commissionrate = 0.085;
position = manager, cooks, salesperson;
cout << "Position category : ";
cin >> position;
if (position = manager)
{
totalincome = managersalary;
}
else if (position = cooks)
{
cout << "input total working hours : ";
cin >> cookstotalworkinghours;
if (cookstotalworkinghours <= 30)
{
totalincome = cookstotalworkinghours * cooksfixedrate;
cout << "total income : " << totalincome;
}
else if (cookstotalworkinghours > 30);
totalincome = (30 * cooksfixedrate) + cookstotalworkinghours - (30*1.5*cooksfixedrate);
cout << "total income : " << totalincome;
}
else if (position = salesperson)
{
cout << "total sales per week : ";
cin >> salespersontotalsales;
totalincome = 300 + (commissionrate * salespersontotalsales);
cout << "total income : "; <<totalincome;
}
return 0;
}
got many errors though..
is my code is correct to calculate the salary ?
A company owned by First Avenue has a salary system based on position level. Employee salary is being paid on a weekly basis. The company has 30 employees, which comprises of a manager (fixed salary), cooks (salary on hourly basis), salesperson (fixed salary and sales commission). Below shows the details of salary payment for each position level.
1) Position level : Manager
Salary paid per week : Fixed salary
2) Position level : Cooks
Salary paid per week : First 30 hours - fixed rate every hour. The next following hours, overtime rate at 1.5% of the fixed rate hourly
3) Position level : Salesperson
Salary paid per week : $300 plus commission 8.5% of the total sales per week.
Calculate the amount of salary received for each employee based on their position level in the company.
Given is the input, output, solution/formula, and constraint for the above problem :
Inputs:
*fixed input:
- fixed salary for a manager
- fixed rate for cooks
- basic salary for salesperson
- commission rate
*user’s input:
- position category
- total working hours for cooks
- total sales for salesperson
Outputs:
- position category
- total income
Solution/Formula:
1) Income for a manager is fixed
2) Income for cooks is calculated by multiply total working hours with fixed rate:
2.1 if total working hours less than or equal 30 hours,
Total income = total working hours * fixed rate
2.2 if total working hours more than 30 hours
Total income = 30 * fixed rate + total working hours – 30 * 1.5 * fixed rate
3) Total income for a salesperson = $300 + commission rate * total sales per
week
Constraints:
- total working hours can not exceed than 168 hours
- total working hours must be entered for cooks
- total sales must be entered for salesperson
so, have to write a C++ program to calculate.
here is the code that i have done :
#include <iostream>
using namespace std;
int main(){
double managersalary, cooksfixedrate, salespersonsalary, commissionrate, cookstotalworkinghours, salespersontotalsales, totalincome;
char position, manager, cooks, salesperson;
managersalary = 1000.00;
cooksfixedrate = 15.00;
salespersonsalary = 300.00;
commissionrate = 0.085;
position = manager, cooks, salesperson;
cout << "Position category : ";
cin >> position;
if (position = manager)
{
totalincome = managersalary;
}
else if (position = cooks)
{
cout << "input total working hours : ";
cin >> cookstotalworkinghours;
if (cookstotalworkinghours <= 30)
{
totalincome = cookstotalworkinghours * cooksfixedrate;
cout << "total income : " << totalincome;
}
else if (cookstotalworkinghours > 30);
totalincome = (30 * cooksfixedrate) + cookstotalworkinghours - (30*1.5*cooksfixedrate);
cout << "total income : " << totalincome;
}
else if (position = salesperson)
{
cout << "total sales per week : ";
cin >> salespersontotalsales;
totalincome = 300 + (commissionrate * salespersontotalsales);
cout << "total income : "; <<totalincome;
}
return 0;
}
got many errors though..
is my code is correct to calculate the salary ?