<%@ page contentType="text/html; charset=GB2312" %>
<%@ page import="java.util.*" %>
<html>
<body bgcolor="pink"><FONT SIZE="3">
<p>请输入三角形的三个边的长度,输入的数字用逗号分割:
<br>
<form action="Example2_1.jsp" method="post" name="form">
<input type="text" name="boy">
<input type="submit" value="送出" name="submit">
</form>
<%! double a[]=new double[3];
String answer=null;
%>
<% int i=0;
boolean b=true;
String s=null;
double result=0;
double a[]=new double[3];
String answer=null;
s=request.getParameter("boy");
if(s!=null){
StringTokenizer fenxi=new StringTokenizer(s," ");
while(fenxi.hasMoreTokens()){
String temp=fenxi.nextToken();
try{
a[i]=Double.parseDouble(temp).doubleValue();
i++;
} catch(NumberFormatException e){
out.print("<br>"+"请输入数字字符");
}
}
if(a[0]+a[1]>a[2]&&a[0]+a[2]>a[1]&&a[2]+a[1]>a[0]&&b=true){
double p=(a[0]+a[1]+a[2])/2;
result=Math.sqrt(p*(p-a[0])*(p-a[1])*(p-a[2]));
out.print("面积:"+result);
}
else{
answer="您输入的山边不能构成一个三角形";
out.print("br"+answer);
}
}
%>
<p>您输入的三边是:
<br>
<%=a[0]%>
<br>
<%=a[1]%>
<br>
<%=a[2]%>
</body>
</html>
改对给分
<%@ page import="java.util.*" %>
<html>
<body bgcolor="pink"><FONT SIZE="3">
<p>请输入三角形的三个边的长度,输入的数字用逗号分割:
<br>
<form action="Example2_1.jsp" method="post" name="form">
<input type="text" name="boy">
<input type="submit" value="送出" name="submit">
</form>
<%! double a[]=new double[3];
String answer=null;
%>
<% int i=0;
boolean b=true;
String s=null;
double result=0;
double a[]=new double[3];
String answer=null;
s=request.getParameter("boy");
if(s!=null){
StringTokenizer fenxi=new StringTokenizer(s," ");
while(fenxi.hasMoreTokens()){
String temp=fenxi.nextToken();
try{
a[i]=Double.parseDouble(temp).doubleValue();
i++;
} catch(NumberFormatException e){
out.print("<br>"+"请输入数字字符");
}
}
if(a[0]+a[1]>a[2]&&a[0]+a[2]>a[1]&&a[2]+a[1]>a[0]&&b=true){
double p=(a[0]+a[1]+a[2])/2;
result=Math.sqrt(p*(p-a[0])*(p-a[1])*(p-a[2]));
out.print("面积:"+result);
}
else{
answer="您输入的山边不能构成一个三角形";
out.print("br"+answer);
}
}
%>
<p>您输入的三边是:
<br>
<%=a[0]%>
<br>
<%=a[1]%>
<br>
<%=a[2]%>
</body>
</html>
改对给分
解决方案 »
- 关于proxool里的 maximum-connection-lifetime 这个属性
- jdbc给oracle数据插入数据时候报错,麻烦各位大神给我看下
- 为什么Jsp比于asp.Net的安全性高?
- 下拉菜单在IE6显示正常,在IE7以上版本,和火狐上面显示出问题?
- 在struts的action中如何调用另一个action
- 哪种执行效率高 请指点 就是想弄明白!谢谢!
- 有关出现异常的问题
- struts 下拉框问题
- 问问题:struts异常 File "/WEB-INF/struts-html.tld" not found,顺便散分,提升java版人气
- 我用Date now=new Date()取得服务器时间,由于服务器时间和本地相差6小时,怎样在now上加6小时?
- 为什么jsf能在tomcat5.5.17中运行却不能在6.0中运行呢?
- 正则
An error occurred at line: 14 in the jsp file: /Example2_1.jsp
Generated servlet error:
Cannot invoke doubleValue() on the primitive type doubleAn error occurred at line: 14 in the jsp file: /Example2_1.jsp
Generated servlet error:
Syntax error on token "=", != expected
因为是新手,才学JSP,见笑了,
可是这么简单的东西还是不知道怎么样去修改,谢谢你们!