Hey guys. Can you take a look at this program. It is suppose to calculate federal and city income taxes withheld for a certain pay period. I use a function to calculate this. It keeps telling me that I have too many intitializers and that my function calculateTaxes uses 'void' illegally. Any help is grealty appreciated.
Code:#include <iostream> #include <cmath> #include <string> #include <iomanip> using namespace std; void calculateTaxes(int depends, double payGross, double& cityTaxDate, double& fedTaxDate, double& payNet, double& withheldCityTax, double& withheldFedTax); int main() { cout << "This program calculates taxes withheld from a weekly paycheck.\n\n"; for(;;) { cout << "Please enter your employee number (-1 to quit).\n\n"; int empNumber; cin >> empNumber; if(empNumber < 0)break; cout << "Please enter your number of dependents.\n\n"; int dependents; cin >> dependents; cout << "Please enter your hourly pay rate.\n\n"; double payRate; cin >> payRate; cout << "Please enter the amount of city income tax withheld to date.\n\n"; double cityTaxToDate; cin >> cityTaxToDate; cout << "Please enter the amount of federal income tax withheld to date.\n\n"; double fedTaxToDate; cin >> fedTaxToDate; cout << "Please enter the number of hours worked this week.\n\n"; double hoursWorked; cin >> hoursWorked; double grossPay = payRate * hoursWorked; double cityTaxWithheld = 0; double fedTaxWithheld = 0; double netPay = 0; void calculateTaxes(dependents, grossPay, cityTaxToDate, fedTaxToDate, netPay, cityTaxWithheld, fedTaxWithheld); cout << "Employee Number: " << empNumber << "\n\n" << "Gross Pay: $" << setprecision(3) << grossPay << "\n\n" << "Net Pay: $" << setprecision(3) << netPay << "\n\n" << "Amount of City Income Tax Withheld: $" << setprecision(3) << cityTaxWithheld << "\n\n" << "Amount of Federal Income Tax Withheld: $" << setprecision(3) << fedTaxWithheld << "\n\n" << "Amount of City Income Tax Withheld to Date: $" << setprecision(3) << cityTaxToDate << "\n\n" << "Amount of Federal Income Tax Withheld to Date: $" << setprecision(3) << fedTaxToDate << "\n\n" << endl; } return 0; } void calculateTaxes(int depends, double payGross, double& cityTaxDate, double& fedTaxDate, double& payNet, double& withheldCityTax, double& withheldFedTax) { if( cityTaxDate < 460) withheldCityTax = payGross * .0115; else withheldCityTax = 0; cityTaxDate += withheldCityTax; withheldFedTax = ((payGross - (depends * 50)) * .2); payNet = (payGross - (withheldCityTax + withheldFedTax)); fedTaxDate += withheldFedTax; }



LinkBack URL
About LinkBacks


