From c6fe12062c5308becbac54d6a27608365e799614 Mon Sep 17 00:00:00 2001 From: cdez Date: Wed, 12 Oct 2022 10:53:22 -0700 Subject: [PATCH] Modified Project 5 +- Modified Project 5 File --- PA05-1012/Project_5.c | 93 ++++++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 45 deletions(-) diff --git a/PA05-1012/Project_5.c b/PA05-1012/Project_5.c index 45362ee..d3666c1 100644 --- a/PA05-1012/Project_5.c +++ b/PA05-1012/Project_5.c @@ -179,33 +179,36 @@ double calculateArizonaTax(double adjustedIncome) // check for baseline bracket // calculate tax for baseline totalAZTax = adjustedIncome * AZ_TAX_BASELINE_RATE; - return totalAZTax; } else if(adjustedIncome < AZ_TAX_FIRST_BRACKET_LIMIT) { // check for first bracket and baseline bracket // calculate tax for first and baseline bracket - incomeLeft = adjustedIncome - (adjustedIncome * AZ_TAX_BASELINE_RATE); - totalAZTax = incomeLeft * AZ_TAX_FIRST_BRACKET_RATE; - return totalAZTax; + totalAZTax = AZ_TAX_BASELINE_LIMIT * AZ_TAX_BASELINE_RATE; + incomeLeft = adjustedIncome - AZ_TAX_BASELINE_LIMIT; + totalAZTax = totalAZTax + (incomeLeft * AZ_TAX_FIRST_BRACKET_RATE); } else if(adjustedIncome < AZ_TAX_SECOND_BRACKET_LIMIT) { // check for second, first, and baseline bracket // calculate tax for second, first, and baseline bracket - incomeLeft = adjustedIncome - (adjustedIncome * AZ_TAX_BASELINE_RATE); - incomeLeft = incomeLeft - (incomeLeft * AZ_TAX_FIRST_BRACKET_RATE); - totalAZTax = incomeLeft * AZ_TAX_SECOND_BRACKET_RATE; - return totalAZTax; + totalAZTax = AZ_TAX_BASELINE_LIMIT * AZ_TAX_BASELINE_RATE; + totalAZTax = totalAZTax + + (AZ_TAX_FIRST_BRACKET_LIMIT * AZ_TAX_FIRST_BRACKET_RATE); + incomeLeft = adjustedIncome - AZ_TAX_FIRST_BRACKET_LIMIT; + totalAZTax = totalAZTax + (incomeLeft * AZ_TAX_SECOND_BRACKET_RATE); } else { // otherwise, apply the max, second, first, and baseline bracket // calculate tax for max, second, first, and baseline bracket - incomeLeft = adjustedIncome - (adjustedIncome * AZ_TAX_BASELINE_RATE); - incomeLeft = incomeLeft - (incomeLeft * AZ_TAX_FIRST_BRACKET_RATE); - incomeLeft = incomeLeft - (incomeLeft * AZ_TAX_SECOND_BRACKET_RATE); - totalAZTax = incomeLeft * AZ_TAX_MAX_RATE; + totalAZTax = AZ_TAX_BASELINE_LIMIT * AZ_TAX_BASELINE_RATE; + totalAZTax = totalAZTax + + (AZ_TAX_FIRST_BRACKET_LIMIT * AZ_TAX_FIRST_BRACKET_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 @@ -245,69 +248,69 @@ double calculateFederalTax(double adjustedIncome) // check for baseline bracket // calculate tax for baseline bracket totalFedTax = adjustedIncome * FED_TAX_BASELINE_RATE; - return totalFedTax; } else if(adjustedIncome < FED_TAX_FIRST_BRACKET_LIMIT) { // check for first bracket and baseline bracket // calculate tax for first and baseline bracket - incomeLeft = adjustedIncome - (adjustedIncome * FED_TAX_BASELINE_RATE); - totalFedTax = incomeLeft * FED_TAX_FIRST_BRACKET_RATE; - return totalFedTax; + totalFedTax = FED_TAX_BASELINE_LIMIT * FED_TAX_BASELINE_RATE; + incomeLeft = adjustedIncome - FED_TAX_BASELINE_LIMIT; + totalFedTax = (incomeLeft * FED_TAX_FIRST_BRACKET_RATE) + totalFedTax; } else if(adjustedIncome < FED_TAX_SECOND_BRACKET_LIMIT) { // check for second, first, and baseline bracket // calculate tax for second, first, and baseline bracket - incomeLeft = adjustedIncome - (adjustedIncome * FED_TAX_BASELINE_RATE); - incomeLeft = incomeLeft - (incomeLeft * FED_TAX_FIRST_BRACKET_RATE); - totalFedTax = incomeLeft * FED_TAX_SECOND_BRACKET_RATE; - return totalFedTax; + totalFedTax = FED_TAX_BASELINE_LIMIT * FED_TAX_BASELINE_RATE; + totalFedTax = totalFedTax + (FED_TAX_FIRST_BRACKET_LIMIT * FED_TAX_FIRST_BRACKET_RATE); + incomeLeft = adjustedIncome - FED_TAX_FIRST_BRACKET_LIMIT; + totalFedTax = (incomeLeft * FED_TAX_SECOND_BRACKET_RATE) + totalFedTax; } else if(adjustedIncome < FED_TAX_THIRD_BRACKET_LIMIT) { // check for third, second, first, and baseline bracket // calculate tax for third, second, first, and baseline bracket - incomeLeft = adjustedIncome - (adjustedIncome * FED_TAX_BASELINE_RATE); - incomeLeft = incomeLeft - (incomeLeft * FED_TAX_FIRST_BRACKET_RATE); - incomeLeft = incomeLeft - (incomeLeft * FED_TAX_SECOND_BRACKET_RATE); - totalFedTax = incomeLeft * FED_TAX_THIRD_BRACKET_RATE; - return totalFedTax; + totalFedTax = FED_TAX_BASELINE_LIMIT * FED_TAX_BASELINE_RATE; + totalFedTax = totalFedTax + (FED_TAX_FIRST_BRACKET_LIMIT * FED_TAX_FIRST_BRACKET_RATE); + totalFedTax = totalFedTax + (FED_TAX_SECOND_BRACKET_LIMIT * FED_TAX_SECOND_BRACKET_RATE); + incomeLeft = adjustedIncome - FED_TAX_SECOND_BRACKET_LIMIT; + totalFedTax = (incomeLeft * FED_TAX_THIRD_BRACKET_RATE) + totalFedTax; } else if(adjustedIncome < FED_TAX_FOURTH_BRACKET_LIMIT) { // check 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); - incomeLeft = incomeLeft - (incomeLeft * FED_TAX_FIRST_BRACKET_RATE); - incomeLeft = incomeLeft - (incomeLeft * FED_TAX_SECOND_BRACKET_RATE); - incomeLeft = incomeLeft - (incomeLeft * FED_TAX_THIRD_BRACKET_RATE); - totalFedTax = incomeLeft * FED_TAX_FOURTH_BRACKET_RATE; - return totalFedTax; + totalFedTax = FED_TAX_BASELINE_LIMIT * FED_TAX_BASELINE_RATE; + totalFedTax = totalFedTax + (FED_TAX_FIRST_BRACKET_LIMIT * FED_TAX_FIRST_BRACKET_RATE); + totalFedTax = totalFedTax + (FED_TAX_SECOND_BRACKET_LIMIT * FED_TAX_SECOND_BRACKET_RATE); + totalFedTax = totalFedTax + (FED_TAX_THIRD_BRACKET_LIMIT * FED_TAX_THIRD_BRACKET_RATE); + incomeLeft = adjustedIncome - FED_TAX_THIRD_BRACKET_LIMIT; + totalFedTax = (incomeLeft * FED_TAX_FOURTH_BRACKET_RATE) + totalFedTax; } else if(adjustedIncome < FED_TAX_FIFTH_BRACKET_LIMIT) { // check 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); - incomeLeft = incomeLeft - (incomeLeft * FED_TAX_FIRST_BRACKET_RATE); - incomeLeft = incomeLeft - (incomeLeft * FED_TAX_SECOND_BRACKET_RATE); - incomeLeft = incomeLeft - (incomeLeft * FED_TAX_THIRD_BRACKET_RATE); - incomeLeft = incomeLeft - (incomeLeft * FED_TAX_FOURTH_BRACKET_RATE); - totalFedTax = incomeLeft * FED_TAX_FIFTH_BRACKET_RATE; - return totalFedTax; + totalFedTax = FED_TAX_BASELINE_LIMIT * FED_TAX_BASELINE_RATE; + totalFedTax = totalFedTax + (FED_TAX_FIRST_BRACKET_LIMIT * FED_TAX_FIRST_BRACKET_RATE); + totalFedTax = totalFedTax + (FED_TAX_SECOND_BRACKET_LIMIT * FED_TAX_SECOND_BRACKET_RATE); + totalFedTax = totalFedTax + (FED_TAX_THIRD_BRACKET_LIMIT * FED_TAX_THIRD_BRACKET_RATE); + totalFedTax = totalFedTax + (FED_TAX_FOURTH_BRACKET_LIMIT * FED_TAX_FOURTH_BRACKET_RATE); + incomeLeft = adjustedIncome - FED_TAX_FOURTH_BRACKET_LIMIT; + totalFedTax = (incomeLeft * FED_TAX_FIFTH_BRACKET_RATE) + totalFedTax; } else { // otherwise, apply the 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); - incomeLeft = incomeLeft - (incomeLeft * FED_TAX_FIRST_BRACKET_RATE); - incomeLeft = incomeLeft - (incomeLeft * FED_TAX_SECOND_BRACKET_RATE); - incomeLeft = incomeLeft - (incomeLeft * FED_TAX_THIRD_BRACKET_RATE); - incomeLeft = incomeLeft - (incomeLeft * FED_TAX_FOURTH_BRACKET_RATE); - incomeLeft = incomeLeft - (incomeLeft * FED_TAX_FIFTH_BRACKET_RATE); - totalFedTax = incomeLeft * FED_TAX_MAX_RATE; + totalFedTax = FED_TAX_BASELINE_LIMIT * FED_TAX_BASELINE_RATE; + totalFedTax = totalFedTax + (FED_TAX_FIRST_BRACKET_LIMIT * FED_TAX_FIRST_BRACKET_RATE); + totalFedTax = totalFedTax + (FED_TAX_SECOND_BRACKET_LIMIT * FED_TAX_SECOND_BRACKET_RATE); + totalFedTax = totalFedTax + (FED_TAX_THIRD_BRACKET_LIMIT * FED_TAX_THIRD_BRACKET_RATE); + totalFedTax = totalFedTax + (FED_TAX_FOURTH_BRACKET_LIMIT * FED_TAX_FOURTH_BRACKET_RATE); + totalFedTax = totalFedTax + (FED_TAX_FIFTH_BRACKET_LIMIT * FED_TAX_FIFTH_BRACKET_RATE); + incomeLeft = adjustedIncome - FED_TAX_FIFTH_BRACKET_LIMIT; + totalFedTax = (incomeLeft * FED_TAX_MAX_RATE) + totalFedTax; } // display results