-
Notifications
You must be signed in to change notification settings - Fork 0
/
exercise1.php
35 lines (32 loc) · 1.45 KB
/
exercise1.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
echo "Price Calculator"."<br /><br />";
echo "<form id = \"form1\" method = \"post\" action=\"exercise1.php\" >";
// Form field to input unit price
echo "<label for=\"unitprice\" >Enter article's unit price</label><br />";
echo "<input id=\"input_price\" type=\"number\" name=\"unitprice\" placeholder=\"\" required=\"required\"><br />";
echo "<br />";
// Form field to input article amount
echo "<label for=\"amount\" >Enter article's amount</label><br />";
echo "<input id=\"input_amount\" type=\"number\" name=\"amount\" placeholder=\"\" required=\"required\"><br />";
echo "<br />";
// Submit button to send form
echo "<input id=\"inputsubmit\" type=\"submit\" name=\"submit\" value=\"SUBMIT\" />";
echo "</form>";
echo "<br />";
if (isset($_POST['submit'])){
$input_unitprice = $_POST["unitprice"];
$input_amount = $_POST["amount"];
$subtotal = $input_unitprice * $input_amount;
$tax_TPS = $subtotal * 0.05;
$tax_TVQ = $subtotal * 0.09975;
$total = $subtotal + $tax_TPS + $tax_TVQ;
echo "The price of purchase without taxes (sub-total) : ".$subtotal;
echo "<br />";
echo "The price for TPS : ".$tax_TPS;
echo "<br />";
echo "The price for TVQ : ".$tax_TVQ;
echo "<br />";
echo "The price of purchase including taxes : ".$total;
echo "<br />";
}
?>