Hello,
I am trying to write up a program that calculates gross salary and other forms of tax to be deducted from the gross to make a net pay.
My program seems to be working fine except for my function double FEDTAX( double). there is a 12% tax for married people and an 18% tax for single people on the fed tax. I am having trouble comparing the marital status and tax that should be deducted in the fed tax function. Any help will be amazing. I have been trying a bunch of things for the last couple of days, but nonof them seems to be working. here's the program.
Code:#include<iostream> #include<string> using namespace std;// ln 5 // Declaring subfunctions and other global variables. double FEDTAX(double); double STATETAX(double); double LOCALTAX(double); int MARITALSTATUS;// int main() { string FIRSTNAME, LASTNAME;// first and last names of employee. char MARITALSTATUS;// Marital status of employee. int CENTS; double HOURS_WORKED, HOURLY_RATE, GROSS, NET, TAX ; // declaring hours worked, hourly rate, gross pay, net pay and tax as long numbers. cout << "Enter the first and last names of your employee: "; cin >> FIRSTNAME >> LASTNAME; cout << " Is " <<" " << FIRSTNAME << " " << LASTNAME << " " << "married?( Enter either 1 if married or 0 if not married): "; cin >> MARITALSTATUS; cout << "Enter the number of hours" << " " << FIRSTNAME << " " << LASTNAME << " " << "worked this"<< " " << "week: "; cin >> HOURS_WORKED; cout << "Enter your hourly rate: "; cin >> HOURLY_RATE; CENTS= HOURS_WORKED*HOURLY_RATE*100;// Calculating pay in cents. GROSS= CENTS/100.0; cout << FIRSTNAME << " " << LASTNAME << endl; cout << HOURS_WORKED << "hours worked at $ " << HOURLY_RATE << "/ hour= $ " << GROSS << endl; TAX= FEDTAX(GROSS); cout << "Federal Taxes= $ " << TAX << endl; NET= GROSS-TAX; TAX= STATETAX(GROSS); cout << "State Taxes = $ " << TAX << endl; NET= NET-TAX; TAX= LOCALTAX(GROSS); cout << "Local Taxes =$" << TAX << endl; NET= NET-TAX; cout << "Net Pay =$" << NET << endl; return 0; } double FEDTAX( double GROSS) { int CENTS, MARITALSTATUS; switch(MARITALSTATUS) { case '1': CENTS= 0.12*GROSS*100; return CENTS/100.0; break; case '0': CENTS= 0.18*GROSS*100; return CENTS/100.0; break; } }//End FEDTAX double STATETAX (double GROSS) { int CENTS; CENTS= 0.0307*GROSS*100; return CENTS/100.0; }// end STATETAX double LOCALTAX(double GROSS) { int CENTS; CENTS= 0.030*GROSS*100; return CENTS/100.0; }// end LOCALTAX



LinkBack URL
About LinkBacks


