Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

More Books

Students also viewed these Databases questions