import java.awt.*;
public class Circle5_2
{
public static void main(String[] args)
{
Frame frame = new Frame();
Circle myCircle = new Circle(100,100,50);
frame.setSize(300, 300);
frame.setBackground(Color.yellow);
frame.add(myCircle);
frame.setVisible(true);
}
}
import java.awt.*;
import java.applet.*;
class Circle extends Applet
{
private int x = 0;
private int y = 0;
private double radius = 0;
public Circle(int x, int y, double radius)
{
this.x = x;
this.y = y;
this.radius = radius;
}
public void paint(Graphics g)
{
g.drawString("Radius: " + getRadius(), 50, 20);
g.drawString("Area: " + getArea(), 50, 40);
g.drawString("Area: " + getCircumference(), 50, 60);
int width = (int)(radius * 2);
int height = (int)(radius * 2);
g.fillOval(x, y, width, height);
}
private double getRadius(){
return radius;
}
private double getArea(){
return Math.PI * radius * radius;
}
private double getCircumference(){
return Math.PI * radius * 2d;
}
}