-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest4.php
More file actions
executable file
·45 lines (37 loc) · 951 Bytes
/
test4.php
File metadata and controls
executable file
·45 lines (37 loc) · 951 Bytes
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
<?php
include 'spacefinder.php';
function findBusyness ($building, $floor, $area){
if (!$building) echo "error , no building indicated \n";
$con = connectToDB();
$currPop = getPopulation($building, $floor, $area, $con);
$maxPop = getMaxPop($building, $floor, $area, $con);
if ($maxPop) {
$percentage = $currPop / $maxPop *100;
} else {
echo "error max pop is zero";
return 0;
}
switch ($percentage){
case $percentage > 100:
echo "Overcrowded";
break;
case $percentage > 70 && $percentage <=100 :
echo "Extremely Busy";
break;
case $percentage > 50 && $percentage <=75 :
echo "Busy";
break;
case $percentage > 10 && $percentage <=50 :
echo "Normal";
break;
case $percentage <= 10 :
echo "Empty";
break;
}
return 0;
}
$building = "Robarts Library";
$floor = 14;
$area = 0;
findBusyness($building, $floor, $area);
?>