1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
#include <iostream>
#include<iomanip>
using namespace std;
//function prototypee
void calcFedTaxes(double, double, double,double&,double&);
void calcNetPay(double, double, double, double&);
void displayInfo(double, double, double);
int main ()
{
double Salary = 0.0;
const double FWTRate = .2;
const double FICARate = .08;
double FWT = .2;
double FICA = .08;
double NetPay = 0.0;
//enter input data
cout <<"enter salary:$";
cin >> salary;
//valida input data
while (salary>0)
{
//valid data
calcFedTaxes (Salary, FWTRate, FICARate, FWT, FICA);
calcNetPay (FWT, FICA, NetPay, Salary);
displayInfo (FWT, FICA, NetPay);
cout << fixed;
cout.precision(0);
cout << "salary: " << salary << endl;
return 0;
} //end of main function
//*****program-defined functions*****
void CalcFedTaxes (double salary, double FwtRate, double FICARate, double &FWT,double &FICA)
{
//calculate federal taxes
FWT = salary * FWTRate;
FICA = salary * FICARate;
} //end of calcFedTaxes function
void CalcNetPay( double salary,double FWT,double FICA,double &Netpay)
{
NetPay=salary-(FWT+FICA);
}//end of calcNetPay function
void displayInfos( double FWT,double FICA,double NetPay)
{
//display the FWT,FICA,NetPay
cout<<"federal withholding tax"<<endl;
cout<<"federal insurance contribution"<<endl;
cout<<"Net Pay"<<endl;
}
|