63 133
Assignments Done
99,1%
Successfully Done
In July 2018

Answer to Question #6645 in C++ for kiran

Question #6645
Write a program that will calculate the salary for employees at the High Fashion retail store. The
program must use two overloaded functions, each named " calcSalary". The first function must
calculate the salary for a permanent employee. It will have one parameter of type "char"
representing the type of duties that the employee performs. The second function will calculate the
salary for a temporary employee. It will have a parameter of type "char" representing the duties of a
temporary worker and a second parameter of type "int" representing the number of hours that the
employee works per month.

The main function should request the user to specify whether the worker is a permanent
employee (represented by the character ‘p’) or temporary employee (represented by the
character ‘t’). The user should then be asked to enter the type of duties performed by the
employee. The possible duties for permanent employees are sales, represented by the character
‘s’ or stock control, represented by the character ‘c’. The possible duties for temporary
employees are merchandising, represented by the character ‘m’ or stock counting, represented
by the character ‘c’. If the employee is temporary, the user must be asked to input the number
of hours that the employee works per month as well. Temporary employees either work 60 hours
or 102 hours per month. The main function should then call the correct overloaded function and display the salary.

Define four double constant variables: "PERM_PER_HOUR_SALES" with a value of " 30.70",
"PERM_PER_HOUR_STOCK" with a value of "28.50", "TEMP_PER_HOUR_MERCH" with a value of "17.90" and "TEMP_PER_HOUR_COUNT" with a value of "16.80", representing the rate per hour to
be used in the calculation of the salary for permanent and temporary employees respectively
according to their duties. Also define an "int" constant variable "PERM_HOURS" with a value of 192
representing the number of hours that a permanent employee works per month.
Expert's answer
#include <iostream>

using namespace std;

const double PERM_PER_HOUR_SALES = 30.7, PERM_PER_HOUR_STOCK = 28.5,
TEMP_PER_HOUR_MERCH = 17.9, TEMP_PER_HOUR_COUNT = 16.8;
const int PERM_HOURS = 192;

double calcSalary(char dutiesType);
double calcSalary(char dutiesType, int hours);

int main(int argc, char ** argv) {
char workerType, dutiesType;
int hours;

// loop for workerType input
do {
& cout<<"Choose a type of worker:\n";
& cout<<"p - permanent\n";
& cout<<"t - temporary\n";
& cin>>workerType;
& if (workerType != 'p' && workerType != 't')
cout<<"Wrong worker type!\n";
}
while (workerType != 'p' && workerType != 't');

if (workerType == 'p') { // permanent worker
& do {
cout<<"Choose a type of duties:\n";
cout<<"s - sales\n";
cout<<"c - stock control\n";
cin>>dutiesType;
if (dutiesType != 's' && dutiesType != 'c')
cout<<"Wrong duties type for permanent worker!\n";
& }
& while (dutiesType != 's' && dutiesType != 'c');
&
& cout<<"Salary: $"<<calcSalary(dutiesType)<<endl;
}
else { // temporary worker
& do {
cout<<"Choose a type of duties:\n";
cout<<"m - merchandising\n";
cout<<"c - stock counting\n";
cin>>dutiesType;
if (dutiesType != 'm' && dutiesType != 'c')
cout<<"Wrong duties type for permanent worker!\n";
& }
& while (dutiesType != 'm' && dutiesType != 'c');
&
& do {
cout<<"Enter the number of hours per month (60 or 102): ";
cin>>hours;
if (hours != 60 && hours != 102)
cout<<"Wrong input hours!\n";
& }
& while (hours != 60 && hours != 102);
&
& cout<<"Salary: $"<<calcSalary(dutiesType, hours)<<endl;
}

system("pause");
return 0;
}

double calcSalary(char dutiesType) {
if (dutiesType == 's')
& return PERM_PER_HOUR_SALES * PERM_HOURS;
if (dutiesType == 'c')
& return PERM_PER_HOUR_STOCK * PERM_HOURS;
return 0;
}
double calcSalary(char dutiesType, int hours) {
if (dutiesType == 'm')
& return TEMP_PER_HOUR_MERCH * hours;
if (dutiesType == 'c')
& return TEMP_PER_HOUR_COUNT * hours;
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Assignment Expert
17.02.12, 15:54

Dear Kiran
You're welcome. We are glad to be helpful.
If you really liked our service please press like-button beside answer field. Thank you!

kiran
17.02.12, 15:52

Thank you so much....this is such a gr8 site...keep up the amazing wrk...

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions