Skip to main content

circumference and arc Length of the circle

Define a class named Circle as described below:

Data Members: radius, angle
Methods : 1) constructor.
2) circleCircumference() to compute the circumference of the circle.
3) arcLength() to compute the length of an arc for a given angle.

Within the main( ) method of the class named CircleDemo, create an object of the class Circle. 
Compute the circle’s circumference when the radius is 20 and the arc length when the angle is 90.




class Circle{
public double radius;
public double angle;
public Circle(double radius, double angle){

}
public double circleCircumference(double radius){
return 2*Math.PI*radius;
}
public double arcLength(double radius, double angle){
return radius*angle;
}
}
public class CircleDemo
{
public static void main(String[] args) {
Circle c1 = new Circle(20,90);
System.out.println("The Circumference of the Circle is "+c1.circleCircumference(20));
System.out.println("The arc Length of the circle is "+c1.arcLength(20,90));
}
}


OUTPUT:

The Circumference of the Circle is 125.66370614359172
The arc Length of the circle is 1800.0


Comments