Problems: PHP turning a student mark to a grade using if elseif || Grade Calculator Using PHP and HTM


gpa calculate


Source Code:

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form method="post" action="index.php">
<label>Marks:</label>
<input type="number" name="number" placeholder="inter u sub. marks"><br>
<input type="submit" name="submit"><br>
</form>

<?php
$num= $_POST['number'];

if ($num>=80) {
echo "GPA: A+";
}
elseif ($num>=70) {
echo "GPA: A";
}
elseif ($num>=60) {
echo "GPA: A-";
}
elseif ($num>=50) {
echo "GPA: B";
}
elseif ($num>=40) {
echo "GPA: C";
}
elseif ($num>=40) {
echo "GPA: D";
}
elseif ($num<40) {
echo "Failed";
}

?>
</body>
</html>

Screenshots of Source Code(Sublime Text):

gpa calculate source code
gpa calculate source code
gpa calculate source code


Output of Browser:

Marks: 55
Submit
GPA: B

Screenshot of  Output(Browser):

gpa calculate source code


Post a Comment

Previous Post Next Post