悲催的二柱子们做小学二年级四则运算题(Javaweb)

Posted vvxvv

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了悲催的二柱子们做小学二年级四则运算题(Javaweb)相关的知识,希望对你有一定的参考价值。

  1 <%@ page language="java" contentType="text/html; charset=utf-8"
  2  pageEncoding="utf-8"%>
  3 <!DOCTYPE html>
  4 <html>
  5 <head>
  6 <body background="C:\\Users\\26624\\Desktop/beijing.jpg">
  7 <meta charset="utf-8">
  8 <%
  9    int y = Integer.parseInt(request.getParameter("numbera"));   
 10    int x = Integer.parseInt(request.getParameter("number"));
 11    String values[] = new String[x];
 12    int sum[]=new int[x];
 13    int i;
 14    for(i=0;i<x;i++)
 15    {
 16        int randNumber1 = (int)Math.floor(Math.random()*100+1);
 17        int randNumber2 = (int)Math.floor(Math.random()*100+1);
 18        int fuhao=(int)Math.floor(Math.random()*4+1);
 19        if(fuhao==1){
 20            values[i]=randNumber1+"+"+randNumber2+"=";
 21            sum[i]=randNumber1+randNumber2;
 22        }
 23        if(fuhao==2){
 24            if(randNumber1>randNumber2){
 25                values[i]=randNumber1+"-"+randNumber2+"=";
 26                sum[i]=randNumber1-randNumber2;
 27            }
 28            else{
 29                values[i]=randNumber2+"-"+randNumber1+"=";
 30                sum[i]=randNumber2-randNumber1;
 31            }
 32        }
 33        if(fuhao==3){
 34            if(randNumber1*randNumber2<=100){
 35                values[i]=randNumber1+"*"+randNumber2+"=";
 36                sum[i]=randNumber1*randNumber2;
 37            }
 38            else{
 39                randNumber1=1;
 40                values[i]=randNumber1+"*"+randNumber2+"=";
 41                sum[i]=1*randNumber2;
 42            }
 43        }
 44        if(fuhao==4){
 45            if(randNumber1<randNumber2){
 46                if(randNumber2%randNumber1==0){
 47                    values[i]=randNumber2+"/"+randNumber1+"=";
 48                    sum[i]=randNumber2/randNumber1;
 49                }
 50                else{
 51                    if(randNumber2%2==0){
 52                        randNumber1=2;
 53                        values[i]=randNumber2+"/"+randNumber1+"=";
 54                        sum[i]=randNumber2/randNumber1;
 55                    }
 56                    else if(randNumber2%3==0){
 57                        randNumber1=3;
 58                        values[i]=randNumber2+"/"+randNumber1+"=";
 59                        sum[i]=randNumber2/randNumber1;
 60                    }
 61                    else if(randNumber2%5==0){
 62                        randNumber1=5;
 63                        values[i]=randNumber2+"/"+randNumber1+"=";
 64                        sum[i]=randNumber2/randNumber1;
 65                    }
 66                    else{
 67                        randNumber1=1;
 68                        values[i]=randNumber2+"/"+randNumber1+"=";
 69                        sum[i]=randNumber2/randNumber1;
 70                    }                 
 71                }                           
 72            }
 73            else if(randNumber2==0){
 74                randNumber2=1;
 75                values[i]=randNumber1+"/"+randNumber2+"=";
 76                sum[i]=randNumber1/randNumber2;
 77            }
 78            else{
 79                if(randNumber1%randNumber2==0){
 80                    values[i]=randNumber1+"/"+randNumber2+"=";
 81                    sum[i]=randNumber1/randNumber2;
 82                }
 83                else{
 84                    values[i]=randNumber1+"/"+randNumber1+"=";
 85                    sum[i]=randNumber1/randNumber1;
 86                }    
 87            }
 88        }
 89    }
 90 %>
 91 <title>小学二年级四则运算</title>
 92 </head>
 93 <body>
 94 <form action="interfacetwo.jsp">
 95 <table>
 96   <tr>
 97    <td>题目</td>
 98    <td>答案</td>
 99   </tr>
100   <% 
101   for(int j=0;j<x;){
102      %>
103   <tr>
104    <%
105    int k=0;
106    while(k<y){
107    %>
108    <td><%=values[j] %></td>
109    <td><input type="text" name="results" /></td>
110    <td><input type="hidden" name="answer" value=<%=sum[j] %>></td>
111    <%
112    if(k<y)
113        k++; 
114    else
115        break;
116    if(j<x)
117        j++;
118    else
119        break;
120    }
121    %>
122   </tr>
123   <% 
124     }
125     %>
126     <tr>
127     <td>
128     <input type="submit" value="提交"/>
129     </td>
130     </tr>
131  </table>
132 </form>
133 </body>
134 </html>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body background="C:\\Users\\26624\\Desktop/beijing.jpg">
<h1>网页版四则运算自动出题系统</h1>
<form action="test.jsp" method="get">
<form action="interfacetwo.jsp" method="get">
<table>
<tr>
    <td>总题数</td>
    <td>
    <input type="text" name="number">
    </td>
</tr>
<tr>
    <td>每行题数</td>
    <td>
    <input type="text" name="numbera">
    </td>    
</tr>
<tr>
    <td>
    <input type="submit" value="开始答题"/>
    </td>
</tr>
</table>
</form>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<body background="C:\\Users\\26624\\Desktop/beijing.jpg">
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body background="C:\\Users\\26624\\Desktop/beijing.jpg">
<%
String results[] = request.getParameterValues("results");
String answer[] = request.getParameterValues("answer");
int tr = 0;
int fa = 0;
for(int i=0;i<results.length;i++){
 if(results[i].equals(answer[i])){
  tr++;%>
  <p>第<%=i+1 %>题正确</p>
  <% 
 }else{
  fa++;%>
  <p>第<%=i+1 %>题错误,正确答案为<%=answer[i] %></p>
  <%
 }
}
%>
<h2>
   答对了<%=tr %>题,答错了<%=fa %></h2>
<form action="interfaceone.jsp">
  <input type="submit" value="重新开始答题"/></td> <a href="interfacethree.jsp"> 结束<a> </body> </html>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body background="C:\\Users\\26624\\Desktop/beijing.jpg">
本次答题结束
</body>
</html>

 

 

 

 

 

 

以上是关于悲催的二柱子们做小学二年级四则运算题(Javaweb)的主要内容,如果未能解决你的问题,请参考以下文章

四则运算2

小学二年级四则运算题

小学生二年级四则运算2.0

用C语言写一个 小学生口算出题系统

苦逼的二柱子的四则运算问题

小学一二年级随机四则运算