<%@?page?contentType="text/html;?charset=gb2312"
????pageEncoding="utf-8"%>
<html><body?bgcolor=cyan><font?size=3>
<form?action=""?method=post?name=form>
????<p>請你輸入a:<input?type="text"?name="a"?>
????<br><p>請你輸入b:<input?type="text"?name="b"?>
????<br><p>請你輸入c:<input?type="text"?name="c"?>
????<br><input?type="submit"value="提交"name=submit?>
????</form>
<%
????String?str_a=request.getParameter("a");
????String?str_b=request.getParameter("b");
????String?str_c=request.getParameter("c");
????double?a=0,b=0,c=0;
%>
<%
???if(str_a==null)
???????str_a="0";
???????str_b="0";
???????str_c="0";
???????
%>
??<%??
???try{
????????????a=Double.valueOf(str_a).doubleValue();
????????????b=Double.valueOf(str_b).doubleValue();
????????????c=Double.valueOf(str_c).doubleValue();
????????????if(a+b>c&&a+c>b&&b+c>a){
????????????double?p=(a+b+c)/2.0;
????????????double?mainji=Math.sqrt(p*(p-a)*(p-b)*(p-c));
????????????out.print("<br>"+"三角形面積:"+mainji);
????}
????else
????????out.print("<br>"+"不能構(gòu)成三角形");
??}
catch(NumberFormatException?e){
????out.print(e);
?????}
????%>????
</font></body></html>
不能算三角形的面積,請哪位大佬幫我看看(JSP代碼)
我有沒有告訴你
2018-05-05 15:20:03