Question
Hello I am using a grading software called zybooks but I am having problems with outputs 1,2,3,4,and 25 to be correct. Any help would be
Hello I am using a grading software called zybooks but I am having problems with outputs 1,2,3,4,and 25 to be correct. Any help would be appreciated
Code:
#include
//Tax rates double rates[]={0.10,0.12,0.22,0.24,0.32,0.35,0.37};
//Tax limit and base tax for single tax payers double singleLimits[]={0,9525,38700,82500,157500,200000,500000}; double singleTaxBase[]={0,952.5,4453.50,14089.50,32089.50,45689.50,150689.50};
//Tax limit and base tax for married taxpayers filing tax jointly double jointLimits[]={0,19050,77400,165000,315000,400000,600000}; double jointTaxBase[]={0,1905,8907,28179,64179,91379,161379};
//Tax limit and base tax for married taxpayers filing tax separately double separateFilingLimits[]={0,9525,38700,82500,157500,200000,300000}; double separateFilingTaxBase[]={0,952.50,4453.50,14089.50,32089.50,45689.50,150689.50};
//Tax limit and base tax for household head double headLimits[]={0,13600,51800,82500,157500,200000,500000}; double headTaxBase[]={0,1360,5944,12696,30696,44298,149298};
/* This function accepts the taxable amount,the tax limits and taxbase and compute the tax and returns to the main() */
double computeTax(double taxableAmount,double limits[],double taxBase[]) { double tax; int i=0; //the while loop finds the appropriate index for the given taxable amount while(taxableAmount>=limits[i]) i++; //compute the tax tax=taxBase[i-1] + (taxableAmount-limits[i-1])*rates[i-1]; return tax; } int main() { string status=""; double taxableamount=0,tax=0; cout>status;
cout>taxableamount;
if(status=="X") tax=computeTax(taxableamount,singleLimits,singleTaxBase); else if(status=="Y1") tax=computeTax(taxableamount,jointLimits,jointTaxBase);
else if(status=="Y2") tax=computeTax(taxableamount,separateFilingLimits,separateFilingTaxBase); else if(status=="Z") tax=computeTax(taxableamount,headLimits,headTaxBase); cout
return 0; }
6.12 Tax Computation Review the following code to understand how the arrays are passed to functions. #includeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started