In: Computer Science
Develop a C++ program that will determine the gross pay and net pay (after taxes). Each employee pays a flat tax of 150.00 on the first 1000.00 dollars earned. If the employee earns less than 1000.00 dollars then he/she pays no taxes. Taxes are computed at 15.5% on all earnings over 1000.00 dollars if the number of dependents is 3 or less and 12.5% if the number of dependents are 4 or more.
Sample input/outpt dialog
Enter # of yours worked: 99.99
Enter rate of pay: 10.00
Enter number of dependents: 2
Results
Gross salary is: $9999.99
Taxes withheld: $99.99
Salary after taxes: $999.99
C++ Program:
#include <iostream>
#include <iomanip>
using namespace std;
//Main function
int main()
{
int hoursWorked, dependents;
double payRate, grossPay, taxes, netPay;
//Reading number of hours worked
cout << "\n Enter # of hours worked:
";
cin >> hoursWorked;
//Reading pay rate
cout << "\n Enter rate of pay: ";
cin >> payRate;
//Reading number of dependents
cout << "\n Enter number of dependents:
";
cin >> dependents;
//Calculating gross pay
grossPay = hoursWorked * payRate;
//If gross pay is less than 1000
dollars
if(grossPay < 1000)
{
taxes = 0;
}
else
{
//Tax for first 1000
dollars
taxes = 150.00;
//Calculating taxes
depending on number of dependents
if(dependents <=
3)
{
//Tax rate @15.5 %
taxes = taxes + ( (grossPay - 1000) * 0.155 );
}
else
{
//Tax rate @12.5 %
taxes = taxes + ( (grossPay - 1000) * 0.125 );
}
}
//Calculating net pay
netPay = grossPay - taxes;
//For two decimal places
cout << fixed <<
setprecision(2);
//Printing results
cout << "\n\n Gross Salary is: $" <<
grossPay;
cout << "\n\n Taxes withheld: $" <<
taxes;
cout << "\n\n Salary after taxes: $"
<< netPay;
cout << "\n\n";
return 0;
}
______________________________________________________________________________________________
Sample Output: