-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgradingtask.php
More file actions
60 lines (53 loc) · 1.23 KB
/
Copy pathgradingtask.php
File metadata and controls
60 lines (53 loc) · 1.23 KB
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
<!DOCTYPE html>
<html>
<head>
<title>Grading</title>
<style>
body{background-color:#C0C0C0;}
form {width: 300px; margin: auto; padding-top: 100px; }
input {padding: 8px 3px; width: 100%; }
#button {width: 70%; margin-left:60px; background-color:#808080;}
table{margin:auto; padding-top:200px;}
</style>
</head>
<body>
<?php
function getgrade($score) {
switch ($score) {
case $score > 79 && $score <= 100:
echo "A";
break;
case $score > 69 && $score <= 79:
echo "B";
break;
case $score > 59 && $score <= 69:
echo "C";
break;
case $score > 49 && $score <= 59:
echo "D";
break;
case $score > 39 && $score <= 49:
echo "E";
break;
case $score >= 0 && $score <= 39:
echo "F";
break;
default:
echo "invalid number";
}
}
?>
<table>
<tr>
<form method="post">
<td><input type="number" name="num" placeholder="enter the score" required></td>
<td><input value="<?php
if(isset($_POST['submit'])) {
$score = $_POST['num'];
echo getgrade($score);}?>" readonly></td>
<td><input type="submit" name="submit" id="button" value="submit"></td>
</form>
</tr>
</table>
</body>
</html>