In: Computer Science
Write a program with two input values, Hours and Rate. The program should first calculate Gross pay, which is your pay before deductions. The program should then calculate the following three deduction amounts: Federal Tax (20% of Gross), State Tax (5% of Gross), Social Security Tax (6.2% of Gross). Then your program should calculate Net pay, which is your Gross pay minus the three deductions. The output should be all five of the calculated values.
As no language so I am solving it in c++, I hope it will not create any problem
so here c++ code goes
#include <iostream>
using namespace std;
void calculation(double hours,double rate){
double gross_pay = hours*rate; // thats how you claculate a gross
pay
cout<<"gross pay is "<<gross_pay<<endl;
double federal_tax = gross_pay/5; // 20% is 20/100 = 1/5 its
federal_tax amount
cout<<"federal_tax is "<<federal_tax<<endl;
double state_tax = gross_pay/20; // 5% is 5/100 = 1/20 its
state_tax amount
cout<<"state tax is "<<state_tax<<endl;
double social_security = gross_pay*(6.2/100);// its social_security
amount
cout<<"social_security is
"<<social_security<<endl;
double net_pay = gross_pay-(federal_tax+state_tax+social_security);
// ist total amount :- net_pay = gross_pay - federal_tax -
social_security - state_tax;
cout<<"net pay amount is "<<net_pay<<endl;
}
int main()
{
/*
Gross pay:-
gross pay is the amount used to calculate employee's wages for an
hourly employee or salary
Basically gross pay is all money employee pays before any
deductions are taken amount
*/
//code for this program
double hours, rate; //taking hours and rate as double
cout<<" enter hours and rate "<<endl;
cin>>hours>>rate;
calculation(hours,rate);
return 0;
}
if any doubt, comment below