Write a program that calculates and gives the monthly salary details for an employee, including all the amounts deducted from an employee's gross salary and the net salary which is due to the employee. The user should enter employee's name and the gross pay of the employee. Each employee has the following deductions taken from his gross pay:
Income Tax: 15%
State Tax: 4.5%
Social Security + Medical Tax: 8.5%
Health Insurance Rs.150
Business rules:
1. Gross salary should always be greater than 0. Else it should print "Salary has to be a positive number".
2. Accept the employee's first name and last name and it should print last name, first name along with the final output.
Note:
The Method and inputs are: void calculateNetSal(char *firstName,char *lastName, double grossSal)
Sample Input and output 1:
Enter the first name
Smith
Enter the last name
Steve
Entet the gross salary
3575
Name : Steve , Smith
Gross Amount: Rs.3575.00
Federal Tax: Rs.536.25
State Tax: Rs.125.13
Social Sec / Medicare: Rs.303.88
Health Insurance: Rs.75.00
Net Pay: Rs.2534.74
Sample Input and output 2:
Enter the first name
Allan
Enter the last name
Ray
Enter the gross salary
-100
Salary has to be a positive number
Income Tax: 15%
State Tax: 4.5%
Social Security + Medical Tax: 8.5%
Health Insurance Rs.150
Business rules:
1. Gross salary should always be greater than 0. Else it should print "Salary has to be a positive number".
2. Accept the employee's first name and last name and it should print last name, first name along with the final output.
Note:
The Method and inputs are: void calculateNetSal(char *firstName,char *lastName, double grossSal)
Sample Input and output 1:
Enter the first name
Smith
Enter the last name
Steve
Entet the gross salary
3575
Name : Steve , Smith
Gross Amount: Rs.3575.00
Federal Tax: Rs.536.25
State Tax: Rs.125.13
Social Sec / Medicare: Rs.303.88
Health Insurance: Rs.75.00
Net Pay: Rs.2534.74
Sample Input and output 2:
Enter the first name
Allan
Enter the last name
Ray
Enter the gross salary
-100
Salary has to be a positive number
#include < iostream >
#include < iomanip >
#include < string >
using namespace std;
int main (void)
{
double Salary,Federal,State,Social,Health,Net;
string name;
cout < < "Enter employee name:" < < endl;
cin > > name;
cout < < endl;
cout < < "Enter salary:" < < endl;
cin > > Salary;
cout < < endl;
if (cin.fail()==true)
{
cout < < "Error, this is not a numericle value." < < endl;
cin.clear();
cin.ignore(50, '\n');
}
else if (Salary < = 0)
{
cout < < "Salary has to be a positive number." < < endl;
}
else
{
Federal = Salary * 0.15;
State = Salary * 0.035;
Social = Salary * 0.085;
Health = 75.00;
Net = Salary - Federal - State - Social - Health;
cout < < fixed < < showpoint < < setprecision(2) < < endl;
cout < < "Federal tax = : " < < Federal < < endl;
cout < < "State tax = : " <cout < < "Social security tax = : " <cout < < "Health deduction = : " < < Health < < endl;
cout < < "Net salary is: " <cout < < "Press any key to exit." < < endl;
}
cin.ignore(2) ;
return 0;
}
#include < iomanip >
#include < string >
using namespace std;
int main (void)
{
double Salary,Federal,State,Social,Health,Net;
string name;
cout < < "Enter employee name:" < < endl;
cin > > name;
cout < < endl;
cout < < "Enter salary:" < < endl;
cin > > Salary;
cout < < endl;
if (cin.fail()==true)
{
cout < < "Error, this is not a numericle value." < < endl;
cin.clear();
cin.ignore(50, '\n');
}
else if (Salary < = 0)
{
cout < < "Salary has to be a positive number." < < endl;
}
else
{
Federal = Salary * 0.15;
State = Salary * 0.035;
Social = Salary * 0.085;
Health = 75.00;
Net = Salary - Federal - State - Social - Health;
cout < < fixed < < showpoint < < setprecision(2) < < endl;
cout < < "Federal tax = : " < < Federal < < endl;
cout < < "State tax = : " <
cout < < "Net salary is: " <
}
cin.ignore(2) ;
return 0;
}
No comments