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.
Program:
//header file
#include
using namespace std;
//main function
int main()
{
//variable data type declrations
double earnings, gross_pay, net_pay;
int n_dependent;
//ask to input data
cout<<"Enter the Employee Earning: ";
cin>>earnings;
cout<<"Enter the number of dependents: ";
cin>>n_dependent;
//if number of depenedent <=3 and earnings is > 1000
if(n_dependent <=3 && earnings > 1000)
{
//calculate gross pay
gross_pay = earnings - 150;
//calculate earnings
earnings = earnings - 1000;
//calculate net_pay
net_pay = earnings - (earnings * 15.5)/100 - 150;
}
//if number of depenedent >3 and earnings is > 1000
else if(n_dependent > 3 && earnings > 1000)
{
//calculate gross pay
gross_pay = earnings - 150;
//calculate taxable earnings
earnings = earnings - 1000;
//calculate net pay
net_pay = earnings - (earnings * 12.5)/100 - 150;
}
//if earning is less than 1000
else
{
gross_pay = earnings;
net_pay = earnings;
}
//display the gross pay and netpay
cout<<"Gross Pay is: "< cout<<"NetPay is: "< return 0; }//end of the program here i have attached various sample run in a single screen shot.
You can also try and execute the program with different data. Output:
------------------------------------------------------------------------------------------------------------------------------------------