在Sqrt.jsp中实现如下功能:输入一三角形三个边的边长,判断是否符合构成三角形的条件.如果符合,则计算三角形的面积.
代码如下:Sqrt.jsp<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page import="java.util.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Sqrt</title>
</head>
<body><center>
请输入三角形三个边长<p>
<form action="" method="post">
第一边长:
<input type="text" name="first"><br>
第二边长:
<input type="text" name="second"><br>
第三边长:
<input type="text" name="third"><br><p>
<input type="submit" name="submit" value="确定">
<input type="reset" name="reset" value="取消"><p>
</form>
<%!
String First;
String Second;
String Third;
%><%
First=request.getParameter("first");
Second=request.getParameter("second");
Third=request.getParameter("third");
double first=Double.valueOf(First).doubleValue();
double second=Double.valueOf(Second).doubleValue();
double third=Double.valueOf(Third).doubleValue();
if(first+second>third && first+third>second && third+second>first){
double p=(first+second+third)/2;
double result=Math.sqrt(p*(p-first)*(p-second)*(p-third))
out.print(result);
}else{
out.print("不能构成三角形");
}
%> </body>
</html>
可是我运行了很多遍,都提示说出错.提示出错如下:D:\Java\WebApplication1\build\generated\src\org\apache\jsp\Sqrt_jsp.java:89: 警告: 编码 GBK 的不可映射字符
out.print("涓嶈兘鏋勬垚涓夎褰?");
^
D:\Java\WebApplication1\build\generated\src\org\apache\jsp\Sqrt_jsp.java:86: 需要 ';'
out.print(result);请大家给看看,这是怎么回事?给解决一下,谢谢了!
代码如下:Sqrt.jsp<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page import="java.util.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Sqrt</title>
</head>
<body><center>
请输入三角形三个边长<p>
<form action="" method="post">
第一边长:
<input type="text" name="first"><br>
第二边长:
<input type="text" name="second"><br>
第三边长:
<input type="text" name="third"><br><p>
<input type="submit" name="submit" value="确定">
<input type="reset" name="reset" value="取消"><p>
</form>
<%!
String First;
String Second;
String Third;
%><%
First=request.getParameter("first");
Second=request.getParameter("second");
Third=request.getParameter("third");
double first=Double.valueOf(First).doubleValue();
double second=Double.valueOf(Second).doubleValue();
double third=Double.valueOf(Third).doubleValue();
if(first+second>third && first+third>second && third+second>first){
double p=(first+second+third)/2;
double result=Math.sqrt(p*(p-first)*(p-second)*(p-third))
out.print(result);
}else{
out.print("不能构成三角形");
}
%> </body>
</html>
可是我运行了很多遍,都提示说出错.提示出错如下:D:\Java\WebApplication1\build\generated\src\org\apache\jsp\Sqrt_jsp.java:89: 警告: 编码 GBK 的不可映射字符
out.print("涓嶈兘鏋勬垚涓夎褰?");
^
D:\Java\WebApplication1\build\generated\src\org\apache\jsp\Sqrt_jsp.java:86: 需要 ';'
out.print(result);请大家给看看,这是怎么回事?给解决一下,谢谢了!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货