创建评分系统PHP

时间:2017-01-04 23:07:24

标签: php html

我需要帮助完成此代码,问题是:

在大学学习的学生通过一个课程作业和一个笔试来检查。评估的两个组成部分最多可带50个分数。审查员使用以下规则来通过或未通过学生。

学生必须获得40%或以上的合计总分才能通过。 总计39%被缓和到40%。

对于分为以下类别的商标,我们知道等级: A = 100-70 B + = 69-60 B = 59-50 C = 49-40 F = 39-0。

我不能为我的生活弄清楚如何完成这个。

<html>
    <head>
        <title>Commision</title>

    <h1>Result of sale commision </h1>
    <?php
        $coursework=$_POST['coursework'];
        if ($coursework>=50) {
            echo ' Your coursework grade cannot be above 50 ';
        } elseif ($coursework<=51) { 
            print "<p>Your initial coursework grade is" .$coursework."</p>"; 
        }
        $written=$_POST['written'];
        if ($written>=50) {
            echo ' written grade cannot be above 50 ';
        } elseif ($written<=51) {
            print "<p> Your initial written grade is" .$written."</p>";
        }

        $total= $written + $coursework;
        print "<p>Your total grade combine is " .$total."</p>";
    ?>
</html>

<html>
    <head>
        <title>Commision</title>

    <h1>Grade calculator </h1>
    <p>This form will allow you to work out grades</p>

    <h2>Provide your grades </h2>

    <form name="commision" action="graderesp.php" method="POST">
        <p>Enter your written examination mark: <input type="text" name="written"></p>
        <p>Enter your coursework mark: <input type="text" name="coursework"></p>

        <p>Thank you for your salary <input type="submit" name="continue" value="Continue" /></p>
    </form>
</html>

1 个答案:

答案 0 :(得分:0)

你想要实现的是什么?根据提供的2个分数为您提供成绩(类别)的代码?

您可以实现切换器状态以实现此目的。伪代码如下:

$workScore = $_POST['coursework'];

switch($workScore) {
case $workScore >= 70 and $workScore <= 100:
    echo 'Your Grade is A';
    break;
case $workScore >= 60 and $workScore <= 69:
    echo 'Your Grade is B+';
    break;
case $workScore >= 59 and $workScore <= 60:
    echo 'Your Grade is B';
    break;
default:
echo 'something else':
}

然后在你得到两个结果:写作和工作后,你计算最终得分并将其发送给最终用户