Modified Project 5

+- Modified Project 5 File
This commit is contained in:
Charles Descamps 2022-10-12 10:53:22 -07:00
parent 7db9595edf
commit c6fe12062c

View file

@ -179,33 +179,36 @@ double calculateArizonaTax(double adjustedIncome)
// check for baseline bracket // check for baseline bracket
// calculate tax for baseline // calculate tax for baseline
totalAZTax = adjustedIncome * AZ_TAX_BASELINE_RATE; totalAZTax = adjustedIncome * AZ_TAX_BASELINE_RATE;
return totalAZTax;
} }
else if(adjustedIncome < AZ_TAX_FIRST_BRACKET_LIMIT) else if(adjustedIncome < AZ_TAX_FIRST_BRACKET_LIMIT)
{ {
// check for first bracket and baseline bracket // check for first bracket and baseline bracket
// calculate tax for first and baseline bracket // calculate tax for first and baseline bracket
incomeLeft = adjustedIncome - (adjustedIncome * AZ_TAX_BASELINE_RATE); totalAZTax = AZ_TAX_BASELINE_LIMIT * AZ_TAX_BASELINE_RATE;
totalAZTax = incomeLeft * AZ_TAX_FIRST_BRACKET_RATE; incomeLeft = adjustedIncome - AZ_TAX_BASELINE_LIMIT;
return totalAZTax; totalAZTax = totalAZTax + (incomeLeft * AZ_TAX_FIRST_BRACKET_RATE);
} }
else if(adjustedIncome < AZ_TAX_SECOND_BRACKET_LIMIT) else if(adjustedIncome < AZ_TAX_SECOND_BRACKET_LIMIT)
{ {
// check for second, first, and baseline bracket // check for second, first, and baseline bracket
// calculate tax for second, first, and baseline bracket // calculate tax for second, first, and baseline bracket
incomeLeft = adjustedIncome - (adjustedIncome * AZ_TAX_BASELINE_RATE); totalAZTax = AZ_TAX_BASELINE_LIMIT * AZ_TAX_BASELINE_RATE;
incomeLeft = incomeLeft - (incomeLeft * AZ_TAX_FIRST_BRACKET_RATE); totalAZTax = totalAZTax +
totalAZTax = incomeLeft * AZ_TAX_SECOND_BRACKET_RATE; (AZ_TAX_FIRST_BRACKET_LIMIT * AZ_TAX_FIRST_BRACKET_RATE);
return totalAZTax; incomeLeft = adjustedIncome - AZ_TAX_FIRST_BRACKET_LIMIT;
totalAZTax = totalAZTax + (incomeLeft * AZ_TAX_SECOND_BRACKET_RATE);
} }
else else
{ {
// otherwise, apply the max, second, first, and baseline bracket // otherwise, apply the max, second, first, and baseline bracket
// calculate tax for max, second, first, and baseline bracket // calculate tax for max, second, first, and baseline bracket
incomeLeft = adjustedIncome - (adjustedIncome * AZ_TAX_BASELINE_RATE); totalAZTax = AZ_TAX_BASELINE_LIMIT * AZ_TAX_BASELINE_RATE;
incomeLeft = incomeLeft - (incomeLeft * AZ_TAX_FIRST_BRACKET_RATE); totalAZTax = totalAZTax +
incomeLeft = incomeLeft - (incomeLeft * AZ_TAX_SECOND_BRACKET_RATE); (AZ_TAX_FIRST_BRACKET_LIMIT * AZ_TAX_FIRST_BRACKET_RATE);
totalAZTax = incomeLeft * AZ_TAX_MAX_RATE; totalAZTax = totalAZTax +
(AZ_TAX_SECOND_BRACKET_LIMIT * AZ_TAX_SECOND_BRACKET_RATE);
incomeLeft = adjustedIncome - AZ_TAX_SECOND_BRACKET_LIMIT;
totalAZTax = totalAZTax + (incomeLeft * AZ_TAX_MAX_RATE);
} }
// display results // display results
@ -245,69 +248,69 @@ double calculateFederalTax(double adjustedIncome)
// check for baseline bracket // check for baseline bracket
// calculate tax for baseline bracket // calculate tax for baseline bracket
totalFedTax = adjustedIncome * FED_TAX_BASELINE_RATE; totalFedTax = adjustedIncome * FED_TAX_BASELINE_RATE;
return totalFedTax;
} }
else if(adjustedIncome < FED_TAX_FIRST_BRACKET_LIMIT) else if(adjustedIncome < FED_TAX_FIRST_BRACKET_LIMIT)
{ {
// check for first bracket and baseline bracket // check for first bracket and baseline bracket
// calculate tax for first and baseline bracket // calculate tax for first and baseline bracket
incomeLeft = adjustedIncome - (adjustedIncome * FED_TAX_BASELINE_RATE); totalFedTax = FED_TAX_BASELINE_LIMIT * FED_TAX_BASELINE_RATE;
totalFedTax = incomeLeft * FED_TAX_FIRST_BRACKET_RATE; incomeLeft = adjustedIncome - FED_TAX_BASELINE_LIMIT;
return totalFedTax; totalFedTax = (incomeLeft * FED_TAX_FIRST_BRACKET_RATE) + totalFedTax;
} }
else if(adjustedIncome < FED_TAX_SECOND_BRACKET_LIMIT) else if(adjustedIncome < FED_TAX_SECOND_BRACKET_LIMIT)
{ {
// check for second, first, and baseline bracket // check for second, first, and baseline bracket
// calculate tax for second, first, and baseline bracket // calculate tax for second, first, and baseline bracket
incomeLeft = adjustedIncome - (adjustedIncome * FED_TAX_BASELINE_RATE); totalFedTax = FED_TAX_BASELINE_LIMIT * FED_TAX_BASELINE_RATE;
incomeLeft = incomeLeft - (incomeLeft * FED_TAX_FIRST_BRACKET_RATE); totalFedTax = totalFedTax + (FED_TAX_FIRST_BRACKET_LIMIT * FED_TAX_FIRST_BRACKET_RATE);
totalFedTax = incomeLeft * FED_TAX_SECOND_BRACKET_RATE; incomeLeft = adjustedIncome - FED_TAX_FIRST_BRACKET_LIMIT;
return totalFedTax; totalFedTax = (incomeLeft * FED_TAX_SECOND_BRACKET_RATE) + totalFedTax;
} }
else if(adjustedIncome < FED_TAX_THIRD_BRACKET_LIMIT) else if(adjustedIncome < FED_TAX_THIRD_BRACKET_LIMIT)
{ {
// check for third, second, first, and baseline bracket // check for third, second, first, and baseline bracket
// calculate tax for third, second, first, and baseline bracket // calculate tax for third, second, first, and baseline bracket
incomeLeft = adjustedIncome - (adjustedIncome * FED_TAX_BASELINE_RATE); totalFedTax = FED_TAX_BASELINE_LIMIT * FED_TAX_BASELINE_RATE;
incomeLeft = incomeLeft - (incomeLeft * FED_TAX_FIRST_BRACKET_RATE); totalFedTax = totalFedTax + (FED_TAX_FIRST_BRACKET_LIMIT * FED_TAX_FIRST_BRACKET_RATE);
incomeLeft = incomeLeft - (incomeLeft * FED_TAX_SECOND_BRACKET_RATE); totalFedTax = totalFedTax + (FED_TAX_SECOND_BRACKET_LIMIT * FED_TAX_SECOND_BRACKET_RATE);
totalFedTax = incomeLeft * FED_TAX_THIRD_BRACKET_RATE; incomeLeft = adjustedIncome - FED_TAX_SECOND_BRACKET_LIMIT;
return totalFedTax; totalFedTax = (incomeLeft * FED_TAX_THIRD_BRACKET_RATE) + totalFedTax;
} }
else if(adjustedIncome < FED_TAX_FOURTH_BRACKET_LIMIT) else if(adjustedIncome < FED_TAX_FOURTH_BRACKET_LIMIT)
{ {
// check for fourth, third, second, first, and baseline bracket // check for fourth, third, second, first, and baseline bracket
// calculate tax for fourth, third, second, first, and baseline bracket // calculate tax for fourth, third, second, first, and baseline bracket
incomeLeft = adjustedIncome - (adjustedIncome * FED_TAX_BASELINE_RATE); totalFedTax = FED_TAX_BASELINE_LIMIT * FED_TAX_BASELINE_RATE;
incomeLeft = incomeLeft - (incomeLeft * FED_TAX_FIRST_BRACKET_RATE); totalFedTax = totalFedTax + (FED_TAX_FIRST_BRACKET_LIMIT * FED_TAX_FIRST_BRACKET_RATE);
incomeLeft = incomeLeft - (incomeLeft * FED_TAX_SECOND_BRACKET_RATE); totalFedTax = totalFedTax + (FED_TAX_SECOND_BRACKET_LIMIT * FED_TAX_SECOND_BRACKET_RATE);
incomeLeft = incomeLeft - (incomeLeft * FED_TAX_THIRD_BRACKET_RATE); totalFedTax = totalFedTax + (FED_TAX_THIRD_BRACKET_LIMIT * FED_TAX_THIRD_BRACKET_RATE);
totalFedTax = incomeLeft * FED_TAX_FOURTH_BRACKET_RATE; incomeLeft = adjustedIncome - FED_TAX_THIRD_BRACKET_LIMIT;
return totalFedTax; totalFedTax = (incomeLeft * FED_TAX_FOURTH_BRACKET_RATE) + totalFedTax;
} }
else if(adjustedIncome < FED_TAX_FIFTH_BRACKET_LIMIT) else if(adjustedIncome < FED_TAX_FIFTH_BRACKET_LIMIT)
{ {
// check for fifth, fourth, third, second, first, and baseline bracket // check for fifth, fourth, third, second, first, and baseline bracket
// calculate tax for fifth, fourth, third, second, first, and baseline bracket // calculate tax for fifth, fourth, third, second, first, and baseline bracket
incomeLeft = adjustedIncome - (adjustedIncome * FED_TAX_BASELINE_RATE); totalFedTax = FED_TAX_BASELINE_LIMIT * FED_TAX_BASELINE_RATE;
incomeLeft = incomeLeft - (incomeLeft * FED_TAX_FIRST_BRACKET_RATE); totalFedTax = totalFedTax + (FED_TAX_FIRST_BRACKET_LIMIT * FED_TAX_FIRST_BRACKET_RATE);
incomeLeft = incomeLeft - (incomeLeft * FED_TAX_SECOND_BRACKET_RATE); totalFedTax = totalFedTax + (FED_TAX_SECOND_BRACKET_LIMIT * FED_TAX_SECOND_BRACKET_RATE);
incomeLeft = incomeLeft - (incomeLeft * FED_TAX_THIRD_BRACKET_RATE); totalFedTax = totalFedTax + (FED_TAX_THIRD_BRACKET_LIMIT * FED_TAX_THIRD_BRACKET_RATE);
incomeLeft = incomeLeft - (incomeLeft * FED_TAX_FOURTH_BRACKET_RATE); totalFedTax = totalFedTax + (FED_TAX_FOURTH_BRACKET_LIMIT * FED_TAX_FOURTH_BRACKET_RATE);
totalFedTax = incomeLeft * FED_TAX_FIFTH_BRACKET_RATE; incomeLeft = adjustedIncome - FED_TAX_FOURTH_BRACKET_LIMIT;
return totalFedTax; totalFedTax = (incomeLeft * FED_TAX_FIFTH_BRACKET_RATE) + totalFedTax;
} }
else else
{ {
// otherwise, apply the max, fifth, fourth, third, second, first, and baseline bracket // otherwise, apply the max, fifth, fourth, third, second, first, and baseline bracket
// calculate tax for max, fifth, fourth, third, second, first, and baseline bracket // calculate tax for max, fifth, fourth, third, second, first, and baseline bracket
incomeLeft = adjustedIncome - (adjustedIncome * FED_TAX_BASELINE_RATE); totalFedTax = FED_TAX_BASELINE_LIMIT * FED_TAX_BASELINE_RATE;
incomeLeft = incomeLeft - (incomeLeft * FED_TAX_FIRST_BRACKET_RATE); totalFedTax = totalFedTax + (FED_TAX_FIRST_BRACKET_LIMIT * FED_TAX_FIRST_BRACKET_RATE);
incomeLeft = incomeLeft - (incomeLeft * FED_TAX_SECOND_BRACKET_RATE); totalFedTax = totalFedTax + (FED_TAX_SECOND_BRACKET_LIMIT * FED_TAX_SECOND_BRACKET_RATE);
incomeLeft = incomeLeft - (incomeLeft * FED_TAX_THIRD_BRACKET_RATE); totalFedTax = totalFedTax + (FED_TAX_THIRD_BRACKET_LIMIT * FED_TAX_THIRD_BRACKET_RATE);
incomeLeft = incomeLeft - (incomeLeft * FED_TAX_FOURTH_BRACKET_RATE); totalFedTax = totalFedTax + (FED_TAX_FOURTH_BRACKET_LIMIT * FED_TAX_FOURTH_BRACKET_RATE);
incomeLeft = incomeLeft - (incomeLeft * FED_TAX_FIFTH_BRACKET_RATE); totalFedTax = totalFedTax + (FED_TAX_FIFTH_BRACKET_LIMIT * FED_TAX_FIFTH_BRACKET_RATE);
totalFedTax = incomeLeft * FED_TAX_MAX_RATE; incomeLeft = adjustedIncome - FED_TAX_FIFTH_BRACKET_LIMIT;
totalFedTax = (incomeLeft * FED_TAX_MAX_RATE) + totalFedTax;
} }
// display results // display results