Tuesday, September 1, 2015

Average Grade Checker in PHP


I have here a program that I wrote in my programming class in PHP before I called this program Average Grade Checker in PHP that will compute the grade of the student from prelim, midterm, prefinal and endterm grading period. The code is very easy to understand and very useful for those you are just starting learning PHP programming.

If you have some questions about programming, about my work please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com. People here in the Philippines can contact me at  my mobile number 09173084360.

Thank you very much and Happy Programming.


Program Listing


<html>
<head> <center> <u> <font size="6" color="darkblue"> Average Grade Checker
<title> Grade Checker </title>
</font> </u> </center> </head>
<body bgcolor="lightgreen">

<?php
error_reporting(0);

if ($_REQUEST['submit'])
{
$prelim=trim($_REQUEST['prelim']);
$midterm=trim($_REQUEST['midterm']);
$pfinal=trim($_REQUEST['pfinal']);
$final=trim($_REQUEST['final']);
$grade=($prelim+$midterm+$pfinal+$final)/4;

if ($grade>=75)
{
echo "<script>";
echo "alert('You Passed.');";
echo "</script>";
}
else
{
echo "<script>";
echo "alert('You Failed.');";
echo "</script>";
}

}

if ($_REQUEST['clear'])
{
$prelim="";
$midterm="";
$pfinal="";
$final="";
$grade="";
}
?>

<form method="post" action="">
<label> Prelim Grade: </label> <br/>
<input type="text" name="prelim" value="<?php echo $prelim; ?>" 
<label> Midterm Grade: </label> <br/>
<input type="text" name="midterm" value="<?php echo $midterm; ?>" 
<label> Prefinal Grade: </label> <br/>
<input type="text" name="pfinal" value="<?php echo $pfinal; ?>" 
<label> Final Grade: </label> <br/>
<input type="text" name="final" value="<?php echo $final; ?>" 
<label> Average Grade: </label> </br>
<input type="text" name="grade" value="<?php echo $grade; ?>" 
<br><br>
<input type="submit" name="submit" value="Submit">
<input type="submit" name="clear" value="Clear">
</form>

</body>
</html>


No comments:

Post a Comment