-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathex3.php
78 lines (59 loc) · 1.7 KB
/
ex3.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<html>
<head>
<style>
div{
margin-top: 30px;
margin-left: 30px;
}
button {
margin: 10px 0 0 30px;
width: 120px;
height: 30px;
}
input {
width: 80px;
height: 25px;
margin-right: 15px;
margin-bottom: 5px;
}
</style>
</head>
<body>
<div>
<form action="" method="GET">
<h2>Enter 10 numbers: </h2>
<input type="number" step= 0.01 name="n0">
<input type="number" step= 0.01 name="n1"> <br>
<input type="number" step= 0.01 name="n2">
<input type="number" step= 0.01 name="n3"> <br>
<input type="number" step= 0.01 name="n4">
<input type="number" step= 0.01 name="n5"> <br>
<input type="number" step= 0.01 name="n6">
<input type="number" step= 0.01 name="n7"> <br>
<input type="number" step= 0.01 name="n8">
<input type="number" step= 0.01 name="n9"> <br>
<button type="submit">Sumbit</button>
</form>
</div>
</body>
</html>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'GET' && isset($_GET['n0'])) {
$tab = [];
for ($i = 0; $i < 10; $i++){
$x = $_GET["n".$i];
$tab[$i] = $x;
}
echo"<br>";
print_r($tab);
$sum = 0;
$average = 0;
$product = 1;
for ($i = 0; $i < 10; $i++){
$sum += $tab[$i];
$product *= $tab[$i];
}
$average = $sum / 10 ;
echo "<br><br>The sum is " . $sum . " <br><br> The average is " . $average . " <br><br> The product is " . $product ;
}
?>