Modified Project 5 File, Added Project 6 Files
+- Project 5 File ++ Project 6 Files (Utils and Main)
This commit is contained in:
parent
8651123e1e
commit
5119f73add
14 changed files with 3021 additions and 39 deletions
|
|
@ -166,8 +166,16 @@ double calculateArizonaTax(double adjustedIncome)
|
|||
// define variables
|
||||
// need a variable that holds the amount of money after the last bracket takes from it.
|
||||
double incomeLeft, totalAZTax;
|
||||
double maxBaselineTax, maxFirstTax, maxSecondTax;
|
||||
incomeLeft = 0;
|
||||
totalAZTax = 0;
|
||||
maxBaselineTax = AZ_TAX_BASELINE_LIMIT * AZ_TAX_BASELINE_RATE;
|
||||
maxFirstTax = maxBaselineTax +
|
||||
(AZ_TAX_FIRST_BRACKET_LIMIT - AZ_TAX_BASELINE_LIMIT)
|
||||
* AZ_TAX_FIRST_BRACKET_RATE;
|
||||
maxSecondTax = maxFirstTax +
|
||||
(AZ_TAX_SECOND_BRACKET_LIMIT - AZ_TAX_FIRST_BRACKET_LIMIT)
|
||||
* AZ_TAX_SECOND_BRACKET_RATE;
|
||||
|
||||
// get input
|
||||
// input is passed in from the function parameter
|
||||
|
|
@ -184,31 +192,22 @@ double calculateArizonaTax(double adjustedIncome)
|
|||
{
|
||||
// check for first bracket and baseline bracket
|
||||
// calculate tax for first and baseline bracket
|
||||
totalAZTax = AZ_TAX_BASELINE_LIMIT * AZ_TAX_BASELINE_RATE;
|
||||
incomeLeft = adjustedIncome - AZ_TAX_BASELINE_LIMIT;
|
||||
totalAZTax = totalAZTax + (incomeLeft * AZ_TAX_FIRST_BRACKET_RATE);
|
||||
totalAZTax = maxBaselineTax + (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
|
||||
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);
|
||||
totalAZTax = maxFirstTax + (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
|
||||
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);
|
||||
totalAZTax = maxSecondTax + (incomeLeft * AZ_TAX_MAX_RATE);
|
||||
}
|
||||
|
||||
// display results
|
||||
|
|
@ -235,8 +234,26 @@ double calculateFederalTax(double adjustedIncome)
|
|||
// need a variable that holds the amount of money after the last bracket takes from it.
|
||||
// as well as a variable to return the amount of tax paid.
|
||||
double incomeLeft, totalFedTax;
|
||||
double maxBaselineTax, maxFirstTax, maxSecondTax, maxThirdTax, maxFourthTax,
|
||||
maxFifthTax;
|
||||
incomeLeft = 0;
|
||||
totalFedTax = 0;
|
||||
maxBaselineTax = FED_TAX_BASELINE_LIMIT * FED_TAX_BASELINE_RATE;
|
||||
maxFirstTax = maxBaselineTax +
|
||||
(FED_TAX_FIRST_BRACKET_LIMIT - FED_TAX_BASELINE_LIMIT)
|
||||
* FED_TAX_FIRST_BRACKET_RATE;
|
||||
maxSecondTax = maxFirstTax +
|
||||
(FED_TAX_SECOND_BRACKET_LIMIT - FED_TAX_FIRST_BRACKET_LIMIT)
|
||||
* FED_TAX_SECOND_BRACKET_RATE;
|
||||
maxThirdTax = maxSecondTax +
|
||||
(FED_TAX_THIRD_BRACKET_LIMIT - FED_TAX_SECOND_BRACKET_LIMIT)
|
||||
* FED_TAX_THIRD_BRACKET_RATE;
|
||||
maxFourthTax = maxThirdTax +
|
||||
(FED_TAX_FOURTH_BRACKET_LIMIT - FED_TAX_THIRD_BRACKET_LIMIT)
|
||||
* FED_TAX_FOURTH_BRACKET_RATE;
|
||||
maxFifthTax = maxFourthTax +
|
||||
(FED_TAX_FIFTH_BRACKET_LIMIT - FED_TAX_FOURTH_BRACKET_LIMIT)
|
||||
* FED_TAX_FIFTH_BRACKET_RATE;
|
||||
|
||||
// get input
|
||||
// input is passed in from the function parameter
|
||||
|
|
@ -253,64 +270,43 @@ double calculateFederalTax(double adjustedIncome)
|
|||
{
|
||||
// check for first bracket and baseline bracket
|
||||
// calculate tax for first and baseline bracket
|
||||
totalFedTax = FED_TAX_BASELINE_LIMIT * FED_TAX_BASELINE_RATE;
|
||||
incomeLeft = adjustedIncome - FED_TAX_BASELINE_LIMIT;
|
||||
totalFedTax = (incomeLeft * FED_TAX_FIRST_BRACKET_RATE) + totalFedTax;
|
||||
totalFedTax = maxBaselineTax + (incomeLeft * FED_TAX_FIRST_BRACKET_RATE);
|
||||
}
|
||||
else if(adjustedIncome < FED_TAX_SECOND_BRACKET_LIMIT)
|
||||
{
|
||||
// check for second, first, and baseline bracket
|
||||
// calculate tax for second, first, and baseline bracket
|
||||
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;
|
||||
totalFedTax = maxFirstTax + (incomeLeft * FED_TAX_SECOND_BRACKET_RATE);
|
||||
}
|
||||
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
|
||||
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;
|
||||
totalFedTax = maxSecondTax + (incomeLeft * FED_TAX_THIRD_BRACKET_RATE);
|
||||
}
|
||||
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
|
||||
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;
|
||||
totalFedTax = maxThirdTax + (incomeLeft * FED_TAX_FOURTH_BRACKET_RATE);
|
||||
}
|
||||
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
|
||||
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;
|
||||
totalFedTax = maxFourthTax + (incomeLeft * FED_TAX_FIFTH_BRACKET_RATE);
|
||||
}
|
||||
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
|
||||
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;
|
||||
totalFedTax = maxFifthTax + (incomeLeft * FED_TAX_MAX_RATE);
|
||||
}
|
||||
|
||||
// display results
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue