Question: I am running into a problem with my logic (I think) when doing this programming exercise. The result should be 5875 for the first test
I am running into a problem with my logic (I think) when doing this programming exercise.
The result should be 5875 for the first test output and 74785.33 for the second output.
It is to calculate the federal tax. Can someone please tell me where I went wrong in my code? I keep outputting 9625 instead
Here is my code
#include
void getData(char &maritalStatus, int &numOfPersons, double &grossSalary, double &pensionPlan, double &pensionFund); double taxAmount(char maritalStatus, int numOfPersons, double grossSalary, double pensionPlan, int numChildren, double pensionFund); double calculateFederalTax(double taxIncome); int main() { // Write your main here char maritalStatus = ' '; int numOfPersons = 0; int numChildren = 0; double grossSalary = 0, pensionFund = 0, pensionPlan = 0; double federalTax =0, taxIncome = 0, taxableIncome = 0; cout<<"Federal tax calculation program: "< double taxAmount(char maritalStatus, int numOfPersons, double grossSalary, double pensionPlan, int numChildren, double pensionFund) { double standExemption = 0; double personalExemption = 1500; double taxableIncome = 0; if (maritalStatus =='m'|| maritalStatus == 'M') standExemption = 7000; else if (maritalStatus =='s'|| maritalStatus=='S') standExemption = 4000; taxableIncome = grossSalary- (standExemption + pensionFund + personalExemption*numOfPersons); return (taxableIncome); } double calculateFederalTax(double taxableIncome) { if(taxableIncome >= 0 && taxableIncome <= 15000) return (taxableIncome * 0.15); else if(taxableIncome >=15001 && taxableIncome <= 40000) return 2250.00 + (taxableIncome * 0.25); else return 8460.00 + (taxableIncome * 0.35); }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
