wages calculator- C++

Task: Wage Calculation
Employees working for XX Company are grouped into 2 categories, Management and Floor Workers.
Normal working hours are 40 hours per week and employees are paid weekly wages. They get paid time and a half for hours exceeding the normal 40 hour limit.
Depending on which category employees fall in, their rate of pay and tax deductions are as follows:
Management:
Hourly Rate: $10.60
Tax Rate: 35%

Floor Workers:
Hourly Rate: $8.30
Tax Rate: 20%
How they want the program to behave is as follows:
Allow the payroll clerk to enter the category of the employee
‘M’ for Management or
‘F’ for Floor Workers
Then enter the number of hours worked
Based on the category entered, calculate the wage earned, taking into consideration overtime pay (if hours worked is > 40) and necessary tax deductions.
Output displayed to the clerk should be in the following format:

Summary:
Staff Category:
Hours worked:
NET WAGE:

Can i get the codes of the above question. it is tough for me.
Please note, that this is not a homework site. We won't do your homework for you. The purpose of homework is that you learn by doing. However we are always willing to help solve problems you encountered, correct mistakes you made in your code and answer your questions.

We didn't see your attempts to solve this problem youself and so we cannot correct mistakes you didn't made and answer questions you didn't ask. To get help you should do something yourself and get real problems with something. If your problem is "I don't understand a thing", then you should go back to basics and study again. As it is impossible to find deriviative of function without knowledge in ariphmetics, you cannot do more complex tasks in programming without clear understanding of basics.
this my attempt.....iam stuck.....i need help..

#include <iostream>
#include <stdlib.h>

using namespace std;

// VARIABLES
int hours_worked;
char employee_category;
double wages;

// CONSTANTS
const double HOURLY_RATE_MANAGEMENT = 10.60;
const double HOURLY_RATE_FLOOR_WORKERS = 8.30;
const double TAX_RATE_MANAGEMENT= 0.35;
const double TAX_RATE_FLOOR =0.20;
const double TIME_AND_HALF = 1.50;

int main ()

{
system ("color 0a"); // changes color of the program

/*welcome message*/

cout << "\t**********************************" << endl;
cout << "\t* WAGE CALCULATOR FOR XX COMPANY *" << endl; //INTRODUCTION
cout << "\t**********************************" << endl;
cout << endl;
// Ask the category of employee
cout << "ENTER CATEGORY: 'M' for Management, 'F' for Floor:[M/F] ";
cin >> employee_category;
cout << "" <<endl;
//How many houers does the employee worked.
cout << "ENTER HOURS WORKED: ";
cin >> hours_worked;
/*VALIDATING INPUT FOR HOURS WORKED*/
while(cin.fail() || hours_worked < 0)
{
if(cin.fail())
{
cin.clear();
string input;
cin>>input;
cout<<"\n\t\""<<input<<"\" This is not a vaild option please try again: ";
cin>>hours_worked;
}
}

//IF THEN ELSE STATEMENT


// if then else for car type = 1 and age is more than 25
if (hours_worked == 40)
{
if (employee_category =='m'||employee_category =='M')
{
wages = (HOURLY_RATE_MANAGEMENT * hours_worked) - ((HOURLY_RATE_MANAGEMENT * hours_worked)*TAX_RATE_MANAGEMENT);
}

}
// DISPLAY THE COST
system ("color 71"); //changes color so you know that cost has been displayed

cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl;
cout << "Your total wages is: $"<< cost <<endl;
cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl;
system ("PAUSE");
return 0;

}
Last edited on
For the future: there is a Source code button on the right of the input field. Use it to make your source easier to read.

I see you have done input already and only struggling with calculations. Do not try to tackle all at once. Do it one step at a time.
First start with calculating wage depending on hours worked. That it, no overtime pay, no tax reducton, nothing else but raw wage.
When you got it working, add overtime pay calculations. When you done that, add taxes to the mix. This way it will be easier to separate large tast into smaller tasks and check everything is working correctly on each step.
I HAVE DONE IT
[code][/
#include <iostream>
#include <stdlib.h>

using namespace std;

// VARIABLES
int hours_worked;
char employee_category;
double net_wage;

// CONSTANTS
const double HOURLY_RATE_MANAGEMENT = 10.60;
const double HOURLY_RATE_FLOOR_WORKERS = 8.30;
const double TAX_RATE_MANAGEMENT= 0.35;
const double TAX_RATE_FLOOR = 0.20;
const double TIME_AND_HALF_M = 15.90;
const double TIME_AND_HALF_F = 12.45;

int main ()

{
system ("color 0a"); // changes color of the program

/*welcome message*/

cout << "\t**********************************" << endl;
cout << "\t* WAGE CALCULATOR FOR XX COMPANY *" << endl; //INTRODUCTION
cout << "\t**********************************" << endl;
cout << endl;
// Ask wheather the driver wants a child seat or no.
cout << "ENTER CATEGORY: 'M' for Management, 'F' for Floor:[M/F]: ";
cin >> employee_category;
cout << "" <<endl;
//How many hours did the employee worked
cout << "ENTER HOURS WORKED: ";
cin >> hours_worked;
//VALIDATION
/*VALIDATING INPUT FOR HOURS WORKED*/
while(cin.fail() || hours_worked < 0)
{
if(cin.fail())
{
cin.clear();
string input;
cin>>input;
cout<<"\n\t\""<<input<<"\" This is not a vaild option please try again: ";
cin>>hours_worked;
}
}

//IF THEN ELSE STATEMENT


// if then else for MANAGEMENT WORKES
if (hours_worked <= 40)
{
if (employee_category =='m'||employee_category =='M')
{
net_wage = (HOURLY_RATE_MANAGEMENT * hours_worked)-((HOURLY_RATE_MANAGEMENT * hours_worked)*TAX_RATE_MANAGEMENT);
}
}
else
{if (hours_worked > 40)
{
if (employee_category =='m'||employee_category =='M')
net_wage = (((HOURLY_RATE_MANAGEMENT * 40)+((hours_worked-40)*TIME_AND_HALF_M))-((HOURLY_RATE_MANAGEMENT * 40)+((hours_worked-40)*TIME_AND_HALF_M))*TAX_RATE_MANAGEMENT);
}
}
// if then else for FLOOR WORKERS

if(hours_worked <= 40)
{
if (employee_category =='f'||employee_category =='F')
{
net_wage = (HOURLY_RATE_FLOOR_WORKERS * hours_worked)-((HOURLY_RATE_FLOOR_WORKERS * hours_worked)*TAX_RATE_FLOOR);
}
}
else
{if (hours_worked > 40)
{
if (employee_category =='f'||employee_category =='F')
net_wage = (((HOURLY_RATE_FLOOR_WORKERS * 40)+((hours_worked-40)*TIME_AND_HALF_F))-((HOURLY_RATE_FLOOR_WORKERS * 40)+((hours_worked-40)*TIME_AND_HALF_F))*TAX_RATE_FLOOR);
}
}
// DISPLAY THE WAGES
system ("color 05"); //changes color so you know that cost has been displayed

cout << "\t\t Summary" << endl;
cout << "\t\t -------" << endl;
cout << "\t\t Staff Category: " << employee_category <<endl;
cout << "\t\t Hours Worked:\t" << hours_worked <<endl;
cout << "\n\t\t NET WAGE: \t$" << net_wage <<endl;

system ("PAUSE");
return 0;

Topic archived. No new replies allowed.