this is past year question:
http://www.psb1.uum.edu.my/ks/Kolej%20Sastera%20dan%20Sains/UUMCASsem1_1516/PUSAT%20TEKNOLOGI%20MEDIA%20%26%20KOMUNIKASI/STIV3013_1_2015_2016.pdf
We discussed about Section B (75%), our lecturer said if you done and know how to do this part, u can pass in the exam..Well, i trust because it is difficult....
ANSWER:
//retrieved information from the form
$name = $_POST["name"];
$matric = $_POST["matric"];
$stiv1023_mark = $_POST["stiv1023_mark"];
$stiv2023_mark = $_POST["stiv2023_mark"];
$stiv3013_mark = $_POST["stiv3013_mark"];
$vkhb2031_mark = $_POST["vkhb2031_mark"];
//calculate grade for each course by calling calculateGred() function
$stiv1023_gred = calculateGred($stiv1023_mark);
$stiv2023_gred = calculateGred($stiv2023_mark);
$stiv3013_gred = calculateGred($stiv3013_mark);
$vkhb2031_gred = calculateGred($vkhb2031_mark);
//calculate point for each course by calling calculatePoint() function
$stiv1023_point = calculatePoint($stiv1023_gred);
$stiv2023_point = calculatePoint($stiv2023_gred);
$stiv3013_point = calculatePoint($stiv3013_gred);
$vkhb2031_point = calculatePoint($vkhb2031_gred);
//calculate TotalPoint based on point for each course and credit
$TotalPoint = $stiv1023_point * 3 + $stiv2023_point * 3 + $stiv3013_point * 3 + $vkhb2031_point * 1;
//calculate GPA based on TotalPoint and total credit
$GPA = $TotalPoint / 10;
//calculate final result by calling calculateResult() function
$result = calculateResult($GPA);
//function to calculate the grade based on mark
function calculateGred($mark)
{
if ($mark >= 90)
$gred = "A";
else if ($mark >= 80)
$gred = "B";
else if ($mark >= 70)
$gred = "C";
else if ($mark >= 60)
$gred = "D";
else if ($mark >= 50)
$gred = "E";
else
$gred = "F";
return $gred;
}
//function to calculate the point based on grade
function calculatePoint($gred)
{
if ($gred == "A")
$point = 4.00;
else if ($gred == "B")
$point = 3.50;
else if ($gred == "C")
$point = 3.00;
else if ($gred == "D")
$point = 2.50;
else if ($gred == "E")
$point = 2.00;
else
$point = 1.00;
return $point;
}
//function to calculate the result based on GPA
function calculateResult($GPA)
{
if ($GPA >= 3.00)
$result = "Pass with distinction";
else if ($GPA >= 2.00)
$result = "Pass";
else
$result = "Fail";
return $result;
}
No comments:
Post a Comment