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
|
#include <iostream>
#include <iomanip>
using namespace std;
//functions
double getSalary();
void calcFedTaxes(double salary, int FWT, int FICA, double &totNetPay);
void calcNetPay(double netPay, int FWT, int FICA, double &totNetPay);
void displayInfo(int FWT, int FICA, double &totNetPay);
void totNetPay(double &totNetPay, double netPay);
int main()
{
//declare variables
double salary = 0.0;
const double FWT = 0.2;
const double FICA = 0.08;
double totNetPay = 0.0;
double netPay = 0.0;
salary = getSalary();
while (salary > 0)
{
calcFedTaxes(salary, FWT, FICA, totNetPay);
calcNetPay(netPay, FWT, FICA, totNetPay);
displayInfo(FWT, FICA, totNetPay);
salary = getSalary();
}//end while
cout << "Total net pay is: " << totNetPay << endl;
system("pause");
return 0;
}
//defining functions
double getSalary()
{
double salaryAmt = 0.0;
cout << "Enter salary amount: (-1 to stop) ";
cin >> salaryAmt;
return salaryAmt;
}
void calcFedTaxes(double salary, int FWT, int FICA, double &totNetPay)
{
FWT = salary * .2;
FICA = salary *.08;
}// end of calcFedTaxes
void calcNetPay(double netPay, int FWT, int FICA, double &totNetPay)
{
totNetPay = netPay + FWT + FICA;
}// end of CalcNetPay
void displayInfo(int FWT, int FICA, double &totNetPay)
{
cout << FWT << endl;
cout << FICA << endl;
cout << totNetPay << endl;
}
void totNetPay(double &totNetPay, double netPay)
{
totNetPay += netPay;
}
|