用JSP重写了四则运算

2021/9/26 23:41:29

本文主要是介绍用JSP重写了四则运算,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

<%@ page contentType="text/html;charset=utf-8" %>
<html>
<head>
<title>
需求信息录入
</title>
</head>
<body>
<h2> 个人注册 </h2>
<form name="form1" method="post" action="NewFile1.jsp">
要打印多少题?:<input name="tishu" type="text"/> <br>
是否应包含*/法?<br />包含:
<input type="radio" checked="checked" name="chengchufa" value="1" />
不包含:
<input type="radio" name="chengchufa" value="2" /><br>
每个式子应有几个数?:<input name="shuziliang" type="text" /> <br>
有无括号?<br>有:
<input type="radio" checked="checked" name="kuohao" value="1" />
无:
<input type="radio" name="kuohao" value="2" /><br>
输入操作数范围:<input name="caozuofanwei" type="text" /> <br>
<input type="submit" value="提交" />
<input type="reset" value="重置" />
</form>
</body>
</html>

 

 

 

<%@ page contentType="text/html;charset=utf-8" %>
<%@ page import="java.util.Random" %>
<html>
<head>
<title> 打印界面 </title>
</head>
<body>
<%
Random a=new Random();
int b=0,c=0,d=0;
int sd = 0,md=0;
String str1=request.getParameter("tishu");
int s=Integer.parseInt(str1);
String str2=request.getParameter("chengchufa");
int m=Integer.parseInt(str2);
String str3=request.getParameter("shuziliang");
int n=Integer.parseInt(str3);
String str4=request.getParameter("kuohao");
int f=Integer.parseInt(str4);
String str5=request.getParameter("caozuofanwei");
int fhm=Integer.parseInt(str5);
String yunsuanfu="+-*/";
for(int i=0;i<s;i++) {
String x="";
if(f==1)
{
sd=a.nextInt()%2;
}
int sf=1,jb=0;
for(int j=0;j<n;j++)
{
b=a.nextInt(fhm)+1;
if(m==1)
d=a.nextInt(4);
else
d=a.nextInt(2);
if(a.nextInt()%2==0&&jb==0&&j<n-1)
{
if(f==1)
{
if(sd==1&&sf==1)
{
x+="(";
sf++;
}
}
jb++;
}
x+=b;
if(f==1&&sf==2)
{
if(sd==1)
if(md%2==1&&md>0)
{
x+=")";
sf=0;
md=0;
}
}
if(j!=n-1)
x+=yunsuanfu.charAt(d);
else
x+="=";
if(sf==2)
md++;
if(j==n-1)
jb=0;
}
out.println(x+"<br>");
}
%>

</body>
</html>

 



这篇关于用JSP重写了四则运算的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程