JAva program that creates aninstance of a circle help

can some one help me? this is what i am trying to complete.. java program that creates an instance of a circle class you create. The circle class should have a data field for radius. Make the class have the default constructor and one that accepts radius input. Also create a getter method for getting the area of the circle.

This is what i have so far, and no luck. Can someone please help me out?

[code]public class RAC06_02
{
// default constructor
private int radius;

double diameter = 2 * radius;
double area = Math.PI * radius * radius;

//Create a circle with a radius of 1.0

public double getRadius() {
return radius;
}
public void setRadius(double radius) {
this.radius =(int) radius;
}
public double getDiameter() {
return diameter;
}
public void setDiameter(double diameter) {
this.diameter = diameter;
}
public double getArea() {
return area;
}
public void setArea(double area) {
this.area = area;
}
public double ComputeDiameter(){
return diameter;
}
public double ComputeArea(){
return area;
}



public static void main(String[] args)
{
RAC06_02 myCircle = new RAC06_02();
RAC06_02 yourCircle = new RAC06_02();
double radius;
double diameter;
double area;
radius = myCircle.getRadius();
diameter = myCircle.getDiameter();
area = myCircle.getArea();
radius = yourCircle.getRadius();
diameter = yourCircle.getDiameter();
area = yourCircle.getArea();
System.out.println("The area of the circle of radius " + radius + "is " + area + "with a diameter of " + diameter);

System.out.println("The area of the circle of radius " + radius + "is " + area + "with a diameter of " + diameter);
}
}

[/code]

Comments

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion