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
70
PA06-1019/Arizona_Tax_Utility.c
Normal file
70
PA06-1019/Arizona_Tax_Utility.c
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
// header file
|
||||
#include "Arizona_Tax_Utility.h"
|
||||
|
||||
// Defined Functions:
|
||||
/*
|
||||
Name: calculateArizonaTax
|
||||
Process: calculates total marginal Arizona tax based on adjusted income
|
||||
Function Input/Parameters: adjustedIncome
|
||||
Function Output/Parameters: none
|
||||
Function Output/Returned: totalAZTax
|
||||
Device Input/Keyboard: none
|
||||
Device Output/Monitor: none
|
||||
Dependencies: none
|
||||
*/
|
||||
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
|
||||
|
||||
// do calculations
|
||||
// use if statements to calculate through the progressive tax brackets
|
||||
if (adjustedIncome < AZ_TAX_BASELINE_LIMIT)
|
||||
{
|
||||
// check for baseline bracket
|
||||
// calculate tax for baseline
|
||||
totalAZTax = adjustedIncome * AZ_TAX_BASELINE_RATE;
|
||||
}
|
||||
else if(adjustedIncome < AZ_TAX_FIRST_BRACKET_LIMIT)
|
||||
{
|
||||
// check for first bracket and baseline bracket
|
||||
// calculate tax for first and baseline bracket
|
||||
incomeLeft = adjustedIncome - AZ_TAX_BASELINE_LIMIT;
|
||||
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
|
||||
incomeLeft = adjustedIncome - AZ_TAX_FIRST_BRACKET_LIMIT;
|
||||
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
|
||||
incomeLeft = adjustedIncome - AZ_TAX_SECOND_BRACKET_LIMIT;
|
||||
totalAZTax = maxSecondTax + (incomeLeft * AZ_TAX_MAX_RATE);
|
||||
}
|
||||
|
||||
// display results
|
||||
// not needed, returns instead.
|
||||
|
||||
// return value
|
||||
// returns the final calculated tax
|
||||
return totalAZTax;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue