`
smartan
  • 浏览: 181979 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

jsp 练习 求三角形面积

阅读更多
求三角形面积 很烂 没注释
以后要写注释
还有 不要忘记{}
尤其是if for 等等 记住了 别老是犯错误


<%@ page contentType="text/html;charset=gb2312"%>
<html>
	<head>


		<title>My JSP 'hello6.jsp' starting page</title>


	</head>

	<body>
		<form action="" method="get" name=form>
			<br>
			qing shuru
			<input type="text" name="a">
			<br>
			qing shuru
			<input type="text" name="b">
			<br>
			qing shuru
			<input type="text" name="c">
			<br>
			<input type="submit" name="submit" value="send">
		</form>
		<%
			String string_a = request.getParameter("a"), string_b = request
					.getParameter("b"), string_c = request.getParameter("c");
			double a = 0, b = 0, c = 0;
		%>
		<%
			if (string_a == null) {
				string_a = "0";
				string_b = "0";
				string_c = "0";
		%>
		<%
			}
			try {
				a = Double.valueOf(string_a).doubleValue();
				b = Double.valueOf(string_b).doubleValue();
				c = Double.valueOf(string_c).doubleValue();
				if (a + b > c && b + c > a && c + a > b) {
					double p = (a + b + c) / 2.0;
					double mianji = Math.sqrt(p * (p - a) * (p - b) * (p - c));
					out.print(mianji);
				} else{
					out.print("nishurudebushisanjiaoxing");
				}
			} catch (NumberFormatException e) {
				out.print("qingshuruzifu");
			}
		%>
	</body>
</html>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics