.java文件:
import java.awt.*;
import java.applet.*;
public class Cir extends Applet
{
public static final double PI = 3.14;
public void paint(Graphics g)
{
double c,s,r=10;
c = 2*r*PI;
s = r*r*PI;
String s1 = Double.toString(c);
String s2 = Double.toString(s);
g.drawString(s1,25,25);
g.drawString(s2,25,50);
}
}
.html文件:
<APPLET CODE="Cir.class" width=200 height=150>
</APPLET>
运行后小窗口的显示的周长怎么不是62.8而是62.800000000000004
|
|