You\'ll have a HTML page with a form that submits a name and an annual income to
ID: 3870388 • Letter: Y
Question
You'll have a HTML page with a form that submits a name and an annual income to a web server. The HTML form will need 2 named textboxes and a submit button. The first allows the user to enter their full name, the second allows the user to enter their taxable income for the year. The income should be a number, so don't enter dollar signs and commas to express the income as currency--just enter the raw number. The HTML form should submit the two textbox values to a php page that will calculate the income tax due on the income.
The second page will be a php page that takes the name and income, and using the table given below, calculates the total tax due for that income. The user's name, income, and tax due should be returned to the user by your php page.
The page returned to the user should have a statement that look like the following, although the wording need not be exact..
Dave Smith, for a taxable income of $70000.00 the tax owed is $16011.25
Shown below is the 2001 Federal Income tax table for single taxpayers. This program requires using If-blocks, so you may have to access recent lecture notes and text assignments before getting a good idea of how to complete the program.
0
$27,050
15% of the income
$27,050
$65,550
$4,057.50 + (27.5% of the amount > $27,050)
$65,550
$136,750
$14,654.00 + (30.5% of the amount > $65,550)
$136,750
$297,350
$36,361.00 + (35.5% of the amount > $136,750)
$297,350 and up
$93,374.00 + (39.1% of the amount > $297,350)
Keep in mind that a number in PHP does not have any non-numeric characters in it. So, your user must enter a straight number, one without dollar signs and commas. And your if-block should not test for numeric values that have dollar signs in them either.
For an example calculation, if a single person's income is 70000, then the tax calculation for tax owed, if everything were numeric literals, would be as follows. You can use this a a check for your calculation of this income bracket.
14654.00 + (.305 * (70000 - 65550)) = 16011.25
Taxable Income from Up to but not including Tax is0
$27,050
15% of the income
$27,050
$65,550
$4,057.50 + (27.5% of the amount > $27,050)
$65,550
$136,750
$14,654.00 + (30.5% of the amount > $65,550)
$136,750
$297,350
$36,361.00 + (35.5% of the amount > $136,750)
$297,350 and up
$93,374.00 + (39.1% of the amount > $297,350)
Explanation / Answer
<?php
$n=_GET("Name");
$i = _GET("TaxableIncome");
$tax=0;
if ($i >=0 && $i< 27050) {
$tax=0.15*$i;
}
elseif ($i >=27050 && $i< 65550) {
$tax=4057.5 + 0.275*($i-27050);
}
elseif ($i >=65550 && $i< 136750) {
$tax=14654 + 0.305*($i-65550);
}
elseif ($i >=136750 && $i< 297350) {
$tax=36361 + 0.355*($i-136750);
}
else{
$tax=93374+0.391*($i-297350);
}
echo $n . ":" . "<BR/>";
echo $tax ;
?>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.