Question: 4. Every circle has a center and a radius. Given the radius, we can determine the circles area and circumference. Given the center, we can

4. Every circle has a center and a radius. Given the radius, we can determine the circles area and circumference. Given the center, we can determine its position in the x-y plane. The center of a circle is a point in the x-y plane. Design the class Circle that can store the radius and center of the circle. Because the center is a point in the x-y plane and you designed the class to capture the properties of a point in Programming Exercise 3, you must derive the class Circle from the class Point. You should be able to perform the usual operations on a circle, such as setting the radius, printing the radius, calculating and printing the area and circumference, and carrying out the usual operations on the center.

Use 3 as a radius to test the program..

HERE is the program for #4 but I am having trouble creating a program for question #5

public class Circle

{ protected double radius; protected double area; protected double circumference; public Circle() { } public Circle(double rad,double area,double circum) { this.radius = rad; this.area = area; this.circumference = circum; } public void setCircle(double rad,double area,double circum) { this.radius = rad; this.area = area; this.circumference = circum; } public void setRadius(double rad) { radius = rad; } public double getRadius() { return radius; } public double area(double a) { return (22*a*a)/7; } public double circumference(double a) { return 2*22*a/7; } public static boolean equals(Circle a,Circle b) { boolean result=false; if(a.getRadius() == b.getRadius()) result = true; else result = false; return result; } public String toString() { return "Cirlce Radius : "+radius+"Circle Area : "+area+"Circle Circumference : "+circumference; } public static void main(String[] args) { boolean result=false; Circle myCircle=new Circle(5.00,4.00,7.23); Circle yourCircle=new Circle(0.00,0.00,0.00); yourCircle.setCircle(5.00,45.00,82.00); myCircle.setRadius(3);

System.out.println("Circle Radius is : "+myCircle.getRadius()); System.out.println("Area of a circle : "+myCircle.area(myCircle.getRadius())); System.out.println("Circumference of a circle : "+myCircle.circumference(myCircle.getRadius())); System.out.println("--------------------------------------------------"); myCircle.toString();

yourCircle.setRadius(3); System.out.println("Circle Radius is : "+yourCircle.getRadius()); System.out.println("Area of a circle : "+yourCircle.area(yourCircle.getRadius())); System.out.println("Circumference of a circle : "+yourCircle.circumference(yourCircle.getRadius())); System.out.println("--------------------------------------------------"); yourCircle.toString(); result = equals(myCircle,yourCircle); if(result == true)

System.out.println("myCircle and yourCircles are equal"); else System.out.println("myCircle and yourCirlces are not equal"); }

}

5. Every cylinder has a base and height, where the base is a circle. Design the class Cylinder that can capture the properties of a cylinder and perform the usual operations on a cylinder. Derive this class from the class Circle designed in Programming Exercise 4. Some of the operations that can be performed on a cylinder are as follows: calculate and print the volume, calculate and print the surface area, set the height, set the radius of the base, and set the center of the base.

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 Databases Questions!