0% found this document useful (0 votes)
26 views3 pages

#Include #Include

This document contains a C++ program that calculates weekly pay for different types of employees using a switch statement. The program prompts the user to enter details for the employee's pay code, which could be 1 for managers with a fixed salary, 2 for hourly workers based on hours worked, 3 for commission workers based on sales, or 4 for pieceworkers based on items produced. For each pay code, the appropriate calculations are performed within the switch to determine the employee's total weekly income and output the result.

Uploaded by

Matte Qurashi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views3 pages

#Include #Include

This document contains a C++ program that calculates weekly pay for different types of employees using a switch statement. The program prompts the user to enter details for the employee's pay code, which could be 1 for managers with a fixed salary, 2 for hourly workers based on hours worked, 3 for commission workers based on sales, or 4 for pieceworkers based on items produced. For each pay code, the appropriate calculations are performed within the switch to determine the employee's total weekly income and output the result.

Uploaded by

Matte Qurashi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 3

Q2: A company pays its employees as managers (who receive a fixed

weekly salary), hourly workers (who receive a fixed hourly wage for up to the
first 40 hours they work and "time-and-a-half"1.5 times their hourly wage for
overtime hours worked), commission workers (who receive $250 plus 5.7
percent of their gross weekly sales), or pieceworkers (who receive a fixed
amount of money per item for each of the items they produce each
pieceworker in this company works on only one type of item). Write a
program to compute the weekly pay for each employee. You do not know the
number of employees in advance. Each type of employee has its own pay
code: Managers have code 1, hourly workers have code 2, commission
workers have code 3 and pieceworkers have code 4. Use a switch to compute
each employee's pay according to that employee's pay_code. Within the
switch, prompt the user (i.e., the payroll clerk) to enter the appropriate facts
your program needs to calculate each employee's pay according to that
employee's pay_code.

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
char employee;
int manager, hourlyworker, pieceworker, commissionworker;
int income, pay1, hours, item, money, sale, income1, pay2, income2, income3;
cout << "Enter 1 for manager,2for hourlyworker,3for comissionworker,4 for
pieceworker" << endl;
cin >> employee;
switch (employee)
{
case '1':
{
cout << "enter weekly income of manager?" << endl;
cin >> income;
cout << "income of manager is: " << income << endl;
break;

}
case '2':
{
cout << "enter per hour income of hourly employee" << endl;
cin >> pay1;
cout << "enter number of hours worker worked!!" << endl;
cin >> hours;
if (hours <= 40)
{
income1 = pay1 * 40;
}
else {
income1 = (pay1 * 40) + (pay1*(hours - 40)*1.5);
}
cout << "Total income of hourly worker" << income1 << endl;
break;
}
case '3':
{
cout << "enter the gross weekly sale?" << endl;
cin >> sale;
income2 = 250 + (0.57*sale);
cout << "total income of comission employee is" << income2 << endl;
break;
}
case '4':
{
cout << "enter amount of money per item?" << endl;
cin >> money;

cout << "enter the number of item employee produce?" << endl;
cin >> item;
income3 = money * item;
cout << "income of the pieceworker is" << income3 << endl;
break;
}

}
_getch();
return 0;
}

You might also like