Question: 3 4 - 3 6 : This should be submitted as two separate . java files. You will need to create the Circle class in

34-36: This should be submitted as two separate .java files. You will need to create the Circle class in the same package as
your class with the main method. Use the code below for your circle class
34. Create a program using the class definition below for a Circle class. In the main method for the program, create an instance of the class called c1 with 2.0 as the radius, and then display the diameter of the circle using the accessor method.
public class Circle {
private double radius;
private double diameter;
public Circle(double rad){
radius = rad;
diameter =2* radius;
}
public double getDiameter(){
return diameter;
}
}
35. Using the Circle class above, add an accessor getCircumference () that uses the radius to compute and return the circumference. Do not add an attribute for circumference. Add an output statement in main to display the result.
Circumference =2* Math.PI * radius
36. Using the Circle class in #34 above, add an accessor method getArea () that uses the readius to compute and return the area. Do not add an attribute for area.
area = Math.PI * radius * radius
From the main method, create a Circle object with a radius of 3.0 and display the diameter, circumference, and area as shown below using 2 decimal places.
Output:
Diameter is 6.0
Circumference is 18.85
Area is 28.27
3 4 - 3 6 : This should be submitted as two

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!