ช่วยหน่อยค่ะ มึนตึ้บ หัวทึบ 5555 JSP

Html File



<html>
    <head>
        <title>Calculation Grade</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
        <div>Calculation Grade</div>
        <form method="post" action="4_3_ProcessingFile.jsp">
        <table cellpadding="3" cellspacing="0" border="0">
            
            <tr>
                <td>Score</td>
                <td><input type="text" name="score" size="25"></td>
            </tr>
            
            <tr>
                <td colspan="2"><input type="submit" value="OK" ></td>
            </tr>
            
        </table>
            
        </form>
    </body>
</html>


  JSP File

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Grade</title>
    </head>
    <body>
        <center><h1>Grade</h1></center>
        <%
            //รับค่าที่ส่งมาจากแบบฟอร์ม
            String S = request.getParameter("score");
            
           int sc= Integer.parseInt(S);
           String Grade;
           if(sc>=80)
                   {
                        out.println(Grade = "A");
                   }
           else if(sc >=70)
                   {
                      out.println(Grade="B");  
                   }
           else if(sc >= 60)
                   {
                     out.println(Grade="C");
                   }
           else if(sc>=50)
                   {
                     out.println(Grade= "D");  
                   }
           else if(sc >=0)
                   {
                       out.println(Grade ="F");
                   }
            return Grade;
        %>
        
        <table cellpadding="2" cellspacing="0" border="1">
        <tr> <td> Grade  </td> <td> <%=Grade%> </td> </tr>
        </table>
        
    </body>
</html>
แสดงความคิดเห็น
โปรดศึกษาและยอมรับนโยบายข้อมูลส่วนบุคคลก่อนเริ่มใช้งาน อ่านเพิ่มเติมได้ที่นี่