1
0
Fork 0
This repository has been archived on 2024-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
PHP_TP1/helloworld4.php

55 lines
1.9 KiB
PHP
Raw Normal View History

2020-09-10 16:01:09 +02:00
<!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>