四则运算
<%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="utf-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>做题页</title> <style type="text/css"> .aaa { text-align: center; font-weight: bold; } .aa { text-align: center; } #tijiao { text-align: center; } #form p label { text-align: center; } #form1{ text-align: center; } .qqq { text-align: center; font-size: 36px; font-family: "微软雅黑"; } </style> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body background="timg.jpg"> <p> </p> <p class="qqq">做题页</p> <p> </p> <p> <form id="form1" name="form1" method="post" action="MyJsp1.jsp"> <table width="386" border="1" align="center"> <tr> <td width="79" height="23" class="aaa">题号</td> <td width="116" class="aaa">题目</td> <td width="169" class="aaa">答案</td> </tr> <% int time1=(int)session.getAttribute("time"); dao.DBUtil db=new dao.DBUtil(); Connection conn =db.getConn(); Statement stmt = conn.createStatement();//从数据库里面取东西对比 ResultSet rs=stmt.executeQuery("select * from yunsuan"); int x=0; int y=1; while(rs.next()) { x++; int num1=rs.getInt("num1"); int num2=rs.getInt("num2"); String symbol=rs.getString("symbol"); %> <table width="386" border="1" align="center"> <tr> <td width="79" height="23" class="aa"><%=y %>.</td> <td width="116" class="aa"><%=num1+symbol+num2 %>=</td> <td width="169" class="aa"> <input type="text" name="<%=x %>" id="<%=x %>" /> </td> </tr> </table> <% y++; } %> </table> <p> </p> <input type="submit" name="tijiao" id="tijiao" value="提交" /> </form> <p> </p> <head> <script type="text/javascript"> var time =<%=time1%>; //时间,秒 function Redirect() { window.location = "MyJsp1.jsp"; } var i = 0; function dis() { document.all.s.innerHTML = "还剩" + (time - i) + "秒"; i++; } timer = setInterval('dis()', 1000); //显示时间 timer = setTimeout('Redirect()', time * 1000); //跳转 </script> </head> <table width="507" border="1" align="center"> <td width="229" class="a" style="text-align: center; color: #F00;"><span id="s"></span></td> </table> </body> </html>
<%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>答案页</title> <style type="text/css"> #form1 p label { text-align: center; } #form1 { text-align: center; } </style> <style type="text/css"> .a { color: #0F0; } .qqq { text-align: center; font-size: 36px; font-family: "微软雅黑"; } </style> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </head> <body background="timg.jpg"> <p> </p> <p class="qqq">结果页</p> <p> </p> <p> <% dao.DBUtil db=new dao.DBUtil(); Connection conn =db.getConn(); Statement stmt = conn.createStatement();//从数据库里面取东西对比 ResultSet rs=stmt.executeQuery("select * from yunsuan"); int x=0; double q=0;//对题数 double p=0;//错题数 while(rs.next()) { x++; String y=String.valueOf(x); int num1=rs.getInt("num1"); int num2=rs.getInt("num2"); String symbol=rs.getString("symbol"); int find=rs.getInt("find"); int a=0; if(request.getParameter(y)!=null&&(!"".equals(request.getParameter(y)))) { a=Integer.parseInt(request.getParameter(y)); } %> </p> <table width="507" border="1" align="center"> <tr> <td width="131" style="text-align: center"><%=num1+symbol+num2 %>=</td> <td width="125" style="text-align: center"><%=a %></td> <% if(find==a) { q++; %> <td width="229" class="a" style="text-align: center">回答正确</td> <% } else { p++; %> <td width="229" class="a" style="text-align: center; color: #F00;">回答错误,正确答案为<%=find %></td> <% } } %> </tr> </table> <% stmt.executeUpdate("delete from yunsuan"); %> <br> <br> <br> <table width="700" border="1" align="center"> <tr> <td width="200" height="23" class="aaa">总题数:<%=q+p%></td> <td width="300" class="aaa">做对<%=q %>题 正确率:<%=q/(q+p)*100 %>%</td> <td width="200" class="aaa">做错<%=p %>题</td> </tr> </table> <form id="form1" name="form1" method="post" action="index.jsp"> <p> </p> <input type="submit" name="tijiao" id="tijiao" value="继续答题" /> </form> </body> </html>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>主页</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> <style type="text/css"> #form2 p { text-align: center; } #form1 p label { text-align: center; } #form1 { text-align: center; } </style> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body background="timg.jpg"> <form id="form2" name="form2" method="post" action=""> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> </form> <form id="form1" name="form1" method="post" action="servlet/YunServlet?method=add"> <p> <span id="form1"> <label for="name">要做的题数:</label> <input type="text" name="num" id="num" /> </span></p> <p> <label for="name2">限制的时间:</label> <input type="text" name="time" id="time" /> </p> <p> <input type="submit" name="tijiao" id="tijiao" align="center" value="提交" /> </p> </form> </body> </html>