软件工程个人作业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

 

 

 

目录
相关文章
|
10月前
|
存储 算法 C++
【C++】——标准模板库STL作业(其三)
【C++】——标准模板库STL作业(其三)
【C++】——标准模板库STL作业(其三)
|
5月前
|
机器学习/深度学习 算法 数据挖掘
机器学习第五次作业
机器学习第五次作业包含三个题目。第一题实现高斯贝叶斯分类和高斯朴素贝叶斯分类,分别用于判断瓜的好坏。第二题使用EM算法对数据进行聚类,输出两个类别的均值、方差和先验概率。第三题内容未完整展示。
83 0
机器学习第五次作业
|
7月前
|
算法
算法设计与分析作业
这篇文章是关于算法设计与分析的作业,其中包含了两个算法实现:一个是使用分治算法实现的十进制大整数相乘(包括加法、减法和乘法函数),并进行了正确性和健壮性测试;另一个是使用快速排序思想实现的分治查找第K小元素的程序,并分析了其平均和最坏时间复杂度。
算法设计与分析作业
|
7月前
|
算法 C++
惊爆!KPM算法背后的秘密武器:一行代码揭秘字符串最小周期的终极奥义,让你秒变编程界周期大师!
【8月更文挑战第4天】字符串最小周期问题旨在找出字符串中最短重复子串的长度。KPM(实为KMP,Knuth-Morris-Pratt)算法,虽主要用于字符串匹配,但其生成的前缀函数(next数组)也可用于求解最小周期。核心思想是构建LPS数组,记录模式串中每个位置的最长相等前后缀长度。对于长度为n的字符串S,其最小周期T可通过公式ans = n - LPS[n-1]求得。通过分析周期字符串的特性,可证明该方法的有效性。提供的C++示例代码展示了如何计算给定字符串的最小周期,体现了KPM算法在解决此类问题上的高效性。
145 0
|
9月前
|
机器学习/深度学习 自然语言处理 Perl
技术经验解读:作业4文法和语言总结与梳理
技术经验解读:作业4文法和语言总结与梳理
53 0
|
10月前
|
算法 C++
【软件设计师备考 专题 】数学基础知识:命题逻辑、谓词逻辑、形式逻辑与数值计算
【软件设计师备考 专题 】数学基础知识:命题逻辑、谓词逻辑、形式逻辑与数值计算
154 0
|
Python
【数据科学导论】实验三:布尔变量与条件语句
【数据科学导论】实验三:布尔变量与条件语句
83 0
|
自然语言处理 算法
第二章 总结及作业(6789B)【编译原理】
第二章 总结及作业(6789B)【编译原理】
192 0
|
开发工具
【排序引论】第四章 车间作业排序问题
【排序引论】第四章 车间作业排序问题
105 0
【排序引论】第四章 车间作业排序问题