JSP程序设计问题

来源:百度知道 编辑:UC知道 时间:2024/06/15 19:46:41
编写一个JSP页面,在页面中声明定义两个方法,getArea(double a)和getLength(double a)在程序片中调用这两个方法,分别计算圆的面积和周长
跪求各位大哥大姐帮帮忙

<%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
<html>
<head>
<title>标题名</title>
<%
double s,c;
public double getArea(double a){
s=3.14*a*a;
return s;
}
public double getLength(double a)
{
c=2*a*3.14;
return c;
}
%>
<body><form action="" name="form1" method="post">
请输入圆的半径:<input type="text" name="r" >
<input type="submit" name="sub" value="提交">
<input type="reset" name="re" value="重置">
</form>
<% String r;double a;
r=request.getParameter("r");
if(r!=null && !r.equal("")){
a=Integer.ParseInt(r);
%>
圆的面积是:<%=getArea()%>
圆的周长是:<%=getLength()%>

</body>
<html><