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,” i.e., 1.5 times their hourly wage, for overtime hours worked), commission workers (who receive a $250 plus 5.7% of their gross weekly sales), or pieceworkers (who receive a fixed amount of money per item for each of the items they produce) __ each piece worker in this company works on only one type of item. Write a program to calculate 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 paycode 1, hourly workers have code 2, commission workers have code 3 and pieceworkers have paycode 4. Use a switch to compute each employee’s pay based on that employee’s paycode. Within the switch, prompt the user (i.e., the payroll check) to enter the appropriate facts your program needs to calculate each employee’s pay based on that employee’s paycode.

#include<iostream>
using namespace std; 

int main()
{
	//Step 1 Ask the user to select paycode
	int paycode,wage,hours,produce;
	double sales,weeklypay,amount;

startcalculation:
	cout<<"Salary Calculator"<<endl;
	cout<<"Please key in paycode number (1-4) to start or 0 to exit"<<endl;
	cout<<"1. Manager"<<endl;
	cout<<"2. Hourly Worker"<<endl;
	cout<<"3. Commission Worker"<<endl;
	cout<<"4. Piece Worker"<<endl;
	cin>>paycode;

	if (paycode<0 || paycode>4)
	{
		cout<<"0-4 only!!!"<<endl;
		goto startcalculation;
	}
//Step 2 Wages Calculation
	switch (paycode)
	{
	case 0:// Exit
		cout<<"Exit Program"<<endl;
		break;
	case 1:// Calculation for paycode1
		cout<<"Input Manager's Salary"<<endl;
		cin>>wage;
		cout<<"Manager's Salary is $"<<wage<<endl;
		break;
	case 2:// Calculation for paycode2
		cout<<"Input hourly rate"<<endl;
		cin>>wage;
		cout<<"Input number of hours worked"<<endl;
		cin>>hours;
		if (hours>40)
		{
			weeklypay=(hours-40)*(wage*1.5);
		}
		else
		{
			weeklypay=wage*hours;
		}
		cout<<"Hourly worker's pay is $"<<weeklypay<<endl;
		break;
	case 3:// Calculation for paycode3
		cout<<"Input gross weekly sales"<<endl;
		cin>>sales;
		{
			weeklypay=250+(0.057*sales);
		}
		cout<<"Commission worker's salary is $"<<weeklypay<<endl;
		break;
	case 4://Calculation for paycode4
		cout<<"Input rate of item"<<endl;
		cin>>wage;
		cout<<"Input amount of items produce"<<endl;
		cin>>amount;
		{
			weeklypay=wage*amount;
		}
		cout<<"Piece worker's salary is $"<<weeklypay<<endl;
		break;
	}
	goto startcalculation;
	

	return 0;
}

and can help me check if it is correct

Just a few logic errors.

First off: the 'produce' variable is not used, so you can delete it.
second: the formula for hourly workers who worked over 40 hours should be:

weeklypay=((hours-40)*wage)*1.5 + 40*wage;

BTW, what is the name of your school that you are learning this in?

Everything else looks good. :)

Just a few logic errors.

First off: the 'produce' variable is not used, so you can delete it.
second: the formula for hourly workers who worked over 40 hours should be:

weeklypay=((hours-40)*wage)*1.5 + 40*wage;

BTW, what is the name of your school that you are learning this in?

Everything else looks good. :)

hi im davind from kaplan anw how to sum the whole thing

hi im davind from kaplan anw how to sum the whole thing

wat do u mean by sum?? wat exactly do u want??

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.