软件工程个人作业2-四则运算2

简介: 四则运算 做题页 .aaa { text-align: center; font-weight: bold;} .

四则运算

<%@ 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>&nbsp;  </p>
  <p class="qqq">做题页</p>
  <p>&nbsp;</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>&nbsp;</p>
    <input type="submit" name="tijiao" id="tijiao"  value="提交" />
    </form>
    <p>&nbsp; </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>
MyJsp
<%@ 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>&nbsp;  </p>
  <p class="qqq">结果页</p>
  <p>&nbsp;</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>&nbsp;</p>
       <input type="submit" name="tijiao" id="tijiao" value="继续答题" />
    </form>
  </body>
</html>
MyJsp1
<%@ 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>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</p>
  <p>&nbsp;</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>
index

 

 

 

目录
相关文章
|
6月前
|
算法 数据处理 C语言
【软件设计师备考 专题 】逻辑运算与算术运算:理解逻辑代数
【软件设计师备考 专题 】逻辑运算与算术运算:理解逻辑代数
103 0
|
6月前
|
C语言
[日常]C语言作业详解12_17(题型对应知识点)
[日常]C语言作业详解12_17(题型对应知识点)
55 0
|
6月前
|
存储 安全 编译器
《C#程序设计》期末大作业复习答案
《C#程序设计》期末大作业复习答案
|
6月前
|
机器学习/深度学习 C语言
C语言实训作业(任务三)
C语言实训作业(任务三)
62 1
|
6月前
|
Shell Windows Perl
Shell编程自动化之数学运算与条件测试
本文主要介绍了Shell编程自动化之数学运算与条件测试,并结合实例测试。
47 0
|
6月前
|
C语言
C语言实训作业(任务二)
C语言实训作业(任务二)
147 0
|
6月前
|
C语言
C语言实训作业(任务一)
C语言实训作业(任务一)
192 0
|
自然语言处理 算法
第二章 总结及作业(6789B)【编译原理】
第二章 总结及作业(6789B)【编译原理】
161 0
|
C# Windows
【C#】【平时作业】习题-4-流程控制
【C#】【平时作业】习题-4-流程控制
123 0
【C#】【平时作业】习题-4-流程控制