-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmathex.php
executable file
·48 lines (35 loc) · 1.03 KB
/
mathex.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>math exercise</title>
</head>
<body>
<fieldset>
<legend>calculate the circumference of a circle</legend>
<form action="mathex.php" method="post">
<label for="">radius (in cm): </label>
<input type="text" name="radius"><br>
<input type="submit" value="calculate"><br>
</form>
</fieldset>
</body>
</html>
<?php
$brx2 = str_repeat("<br>", 2);
$pi = pi();
$radius = $_POST["radius"];
$circumference = 2 * $pi * $radius;
$circumference = round($circumference, 2);
$area = $pi * $radius ** 2;
$area = round($area, 2);
$volume = 4/3 * $pi * pow($radius, 3);
$volume = round($volume, 2);
echo "<br>
Circle's radius: {$radius}cm{$brx2}
Circle's circumference: {$circumference}cm{$brx2}
Circle's area: {$area}cm^2{$brx2}
Sphere's volume: {$volume}cm^3{$brx2}
";
?>