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 #include using namespace std;

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: "<> maritalStatus; if (maritalStatus == 'm' || maritalStatus == 'M') { cout<<"Enter number of children under age 14: "; cin>>numChildren; numOfPersons = 2 + numChildren; cout <<"Enter combined salary: "; cin >>grossSalary; cout<> grossSalary; cout<>grossSalary; cout<> pensionPlan; while(pensionPlan > 6.00) { cout<<"The limit is 6%"<> pensionPlan; } pensionPlan = pensionPlan/100; pensionFund = pensionPlan * grossSalary; cout<

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!