-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPractical2.php
53 lines (46 loc) · 1.04 KB
/
Practical2.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
<?php
/*
B.Tech Computer Science and Engineering
Ayush Kumar
202103103510253
*/
$result = [[],[],[]];
for($i = 0; $i < 3; $i++) {
printf("\n\nEnter result of %d student\n", ($i+1));
for($j = 0; $j < 3; $j++) {
$result[$i][$j] = readline("Enter Result: ");
}
}
function selectStudent($choice) {
global $result;
switch($choice) {
case "1":
$avg = ($result[0][0] + $result[0][1] + $result[0][2])/3;
checkGrade($avg);
break;
case "2":
$avg = ($result[1][0] + $result[1][1] + $result[1][2])/3;
checkGrade($avg);
break;
case "3":
$avg = ($result[2][0] + $result[2][1] + $result[2][2])/3;
checkGrade($avg);
break;
default:
echo "Student doesn't exist\n";
}
}
function checkGrade($avg) {
if($avg > 80) {
echo "You got A grade\n";
} elseif(80 > $avg || $avg > 60) {
echo "You got B grade\n";
} elseif(60 > $avg || $avg > 40) {
echo "You got C grade\n";
} else {
echo "You got D grade\n";
}
}
$roll = readline("Enter your roll no.: ");
selectStudent($roll);
?>