Question
CS 602 Server Side development hw4 please explain and comment the following php code define('TAX_RATES', array( 'Single' => array( 'Rates' => array(10,15,25,28,33,35,39.6), 'Ranges' => array(0,9275,37650,91150,190150,413350,415050),
CS 602 Server Side development hw4 please explain and comment the following php code
define('TAX_RATES', array( 'Single' => array( 'Rates' => array(10,15,25,28,33,35,39.6), 'Ranges' => array(0,9275,37650,91150,190150,413350,415050), 'MinTax' => array(0, 927.50,5183.75,18558.75,46278.75,119934.75,120529.75) ), 'Married_Jointly' => array( 'Rates' => array(10,15,25,28,33,35,39.6), 'Ranges' => array(0,18550,75300,151900,231450,413350,466950), 'MinTax' => array(0, 1855.00,10367.50,29517.50,51791.50,111818.50,130578.50) ), 'Married_Separately' => array( 'Rates' => array(10,15,25,28,33,35,39.6), 'Ranges' => array(0,9275,37650,75950,115725,206675,233475), 'MinTax' => array(0, 927.50,5183.75,14758.75,25895.75,55909.25,65289.25) ), 'Head_Household' => array( 'Rates' => array(10,15,25,28,33,35,39.6), 'Ranges' => array(0,13250,50400,130150,210800,413350,441000), 'MinTax' => array(0, 1325.00,6897.50,26835.00,49417,116258.50,125936) ) ) );
function incomeTax($taxableIncome, $status) {
if ($taxableIncome < 0) return 0;
$ranges = TAX_RATES[$status]['Ranges']; $mins = TAX_RATES[$status]['MinTax']; $tax_brackets = TAX_RATES[$status]['Rates'];
$incTax = 0.0;
$index = count($ranges); for ($i = count($ranges) - 1; $i >= 0; $i--) { if ($taxableIncome > $ranges[$i]) { $index = $i; break; } } $incTax = $mins[$index] + $tax_brackets[$index] * ($taxableIncome - $ranges[$index])/100.0;
return $incTax; }
?>
HW4 Part2 - Kalathur
Income Tax Calculator
Enter Net Income:
Submit
if(isset($_POST['netIncome'])) { $netIncome = $_POST['netIncome']; $incTaxSingle = incomeTax($netIncome, 'Single');
$incomeTaxJointly = incomeTax($netIncome, 'Married_Jointly'); $incomeTaxSeparately = incomeTax($netIncome, 'Married_Separately'); $incomeTaxHeadOfHousehold = incomeTax($netIncome, 'Head_Household'); ?>
With a net taxable income of $
Status | Tax |
---|---|
Single | $ |
Married Filing Jointly | $ |
Married Filing Separately | $ |
Head of Household | $ |
2016 Tax Tables
foreach (TAX_RATES as $status => $status_data) { $ranges = $status_data['Ranges']; $mins = $status_data['MinTax']; $tax_brackets = $status_data['Rates']; $len = count($ranges); ?>
for ($i = 1; $i < ($len-1); $i++) { ?>
Taxable Income | Tax Rate |
---|---|
$ - $ | % |
$ - $ | $ plus % of the amount over $ |
$ or more | $ plus % of the amount over $ |
Step 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