Make helloworld4
This commit is contained in:
parent
11d443985f
commit
7eb62d14ef
1 changed files with 55 additions and 0 deletions
55
helloworld4.php
Normal file
55
helloworld4.php
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Hello World 4</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<?php
|
||||||
|
$children = 0;
|
||||||
|
$married = false;
|
||||||
|
$income = 0;
|
||||||
|
if (isset($_GET["children"]) AND isset($_GET["income"])) {
|
||||||
|
$children = (int)$_GET["children"];
|
||||||
|
if (isset($_GET["married"]))
|
||||||
|
$married = (bool)$_GET["married"];
|
||||||
|
else
|
||||||
|
$married = false;
|
||||||
|
$income = (float)$_GET["income"];
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<form>
|
||||||
|
<label for="children">Number of children: </label>
|
||||||
|
<input id="children" type="number" name="children" min="0" value="<?= $children ?>" required> <br />
|
||||||
|
<label for="married">Married: </label>
|
||||||
|
<input id="married" type="checkbox" name="married" <?= $married ? "checked" : "" ?>> <br />
|
||||||
|
<label for="income">Income: </label>
|
||||||
|
<input id="income" type="number" name="income" min="0" step="any" value="<?= $income ?>" required> <br />
|
||||||
|
<input type="submit" value="Send">
|
||||||
|
</form>
|
||||||
|
<?php
|
||||||
|
if ($married)
|
||||||
|
$n = 2+$children/2;
|
||||||
|
else
|
||||||
|
$n = 1+$children/2;
|
||||||
|
|
||||||
|
$q = $income/$n;
|
||||||
|
|
||||||
|
$t = 0;
|
||||||
|
if ($q >= 0 AND $q <= 9963)
|
||||||
|
$t = $income*0 - 0*$n;
|
||||||
|
elseif ($q >= 9964 AND $q <= 27518)
|
||||||
|
$t = $income*0.14 - 1394.96*$n;
|
||||||
|
elseif ($q >= 27519 AND $q <= 73778)
|
||||||
|
$t = $income*0.3 - 5798*$n;
|
||||||
|
elseif ($q >= 73779 AND $q <= 156243)
|
||||||
|
$t = $income*0.41 - 13913.69*$n;
|
||||||
|
elseif ($q >= 156244)
|
||||||
|
$t = $income*0.45 - 20163.45*$n;
|
||||||
|
|
||||||
|
$t = round($t);
|
||||||
|
|
||||||
|
?>
|
||||||
|
<p>Your taxes is <?= $t ?></p>
|
||||||
|
</body>
|
||||||
|
</html>
|
Reference in a new issue