doutuo3899 2017-01-04 23:07
浏览 50
已采纳

创建PHP评分系统

I need help finishing this code, the question is:

A student studying at university is examined by one piece of coursework and one written examination. Both components of the assessment carry a maximum of 50 marks. The following rules are used by the examiners in order to pass or fail students.

A student must score a combined total mark of 40% or more to pass. A total of 39% is moderated to 40%.

Grades are awared on marks that fall into the following categories: A=100-70 B+=69-60 B=59-50 C=49-40 F=39-0.

I can’t for the life of me figure out how to complete this.

<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条回答 默认 最新

  • dongqi6486 2017-01-04 23:22
    关注

    what is exactly what you are trying to achieve ? A code that gives you your grade ( in categories ) based on the provided 2 scores ?

    You could implement switch statment in order to achieve this. The pseudo code goes like this:

    $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':
    }
    

    Then after you have both results: written and work, then you calculate you final score and send it to the end user

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?