<%@ page contentType="text/html;charset=GB2312" %>
<html>
<body bgcolor=cyan>
<font size=4>
<title>
p14例2-3
</title>
<%! final double PI=Math.PI;
double r;
double getArea(double a){
return PI*a*a;
}
double getLength(double a){
return 2*PI*a;
}
%>
<% r=100;
out.println("调用getArea方法计算半径是"+r+"的圆的面积:");
double area=getArea(r);
out.println(area);
r=50;
out.println("<BR>调用getLength方法计算半径是"+r+"的圆的周长是:");
double length=getLength(r);
out.println(length);
%>
</font>
</body>
</html>
例2-3用jsp程序计算圆的面积和周长
最新推荐文章于 2023-05-24 18:11:27 发布