cal.html
<html>
<body>
<form name="form1" method="post" action="docal.jsp">
<center>
請輸入直角邊1的長:<input type = "text" name = "arg1">
<br>
請輸入直角邊2的長:<input type = "text" name = "arg2">
<br>
<input type = "submit" name = "計算">
</center>
</form>
</body>
</html>
docal.jsp
/*如何算一個直角三角形的 面積,首先要取三角形的兩個直角邊長,面積是兩個直角邊長之積的1/2;*/
<%@ page contentType="text/html;charset=GB2312"%>
<html>
<body>
<center>
<font size="20" color="blue">
<%
int a=Integer.parseInt(request.getParameter("arg1"));
int b=Integer.parseInt(request.getParameter("arg2"));
int s=a*b/2;
out.print("直角三角形邊1的長度是:"+a+"<br>");
out.print("直角三角形邊2的長度是:"+b+"<br>");
out.print("直角三角形的 面積是:"+s+"<br>");
%>
</font>
</center>
</body>
</html>
posted on 2009-05-03 11:05
鵬凌 閱讀(1019)
評論(0) 編輯 收藏