主题:请教 牛人
<%@ page contentType="text/html;charset=gb2312" language="java" %>
<html>
<body>
<p>请输入圆的半径:</P>
<br>
<form action="Circle.jsp" method="get" name="form1">
<input type="text" size="30" name="a">
<input type="submit" value="计算" name="Submit">
</form>
<%
public class Circle{
private double a;
Circle(double a){
this.a=a;
}
double area(){
return a*a*3.14;
}
double perimeter(){
return 2*a*3.14;
}
}
%>
<% String str=request.getParameter("a");
double r=0.0;
if(str!=null){
try{
r=Double.valueOf(str);
}
catch(NumberFormatException e){
out.println("<br>"+"请输入数字");
}
}
else{
r=1.0;
}
Circle cir=new Circle(r);
%>
<p>圆的面积:
<br>
<%=cir.area()%>
<br>
<p>圆的周长:
<br>
<%=cir.perimeter()%>
</body>
</html>
到底哪里错了,怎么编译总是报错
<html>
<body>
<p>请输入圆的半径:</P>
<br>
<form action="Circle.jsp" method="get" name="form1">
<input type="text" size="30" name="a">
<input type="submit" value="计算" name="Submit">
</form>
<%
public class Circle{
private double a;
Circle(double a){
this.a=a;
}
double area(){
return a*a*3.14;
}
double perimeter(){
return 2*a*3.14;
}
}
%>
<% String str=request.getParameter("a");
double r=0.0;
if(str!=null){
try{
r=Double.valueOf(str);
}
catch(NumberFormatException e){
out.println("<br>"+"请输入数字");
}
}
else{
r=1.0;
}
Circle cir=new Circle(r);
%>
<p>圆的面积:
<br>
<%=cir.area()%>
<br>
<p>圆的周长:
<br>
<%=cir.perimeter()%>
</body>
</html>
到底哪里错了,怎么编译总是报错