Question: Sphere Point -radius: double -center: Point -color: String +Sphere) +Sphere (radius: double, center: Point, color: String) +getCenter():Point +calculateVolume(): double +is Equal(sphere:Shpere):boolean +toString(): String Question 1:

 Sphere Point -radius: double -center: Point -color: String +Sphere) +Sphere (radius:

Sphere Point -radius: double -center: Point -color: String +Sphere) +Sphere (radius: double, center: Point, color: String) +getCenter():Point +calculateVolume(): double +is Equal(sphere:Shpere):boolean +toString(): String Question 1: -x: double -y: double -2: double +Point) +Point(x: double, y: double, z: double) +calculate Distance(point :Point) double +is Equal point : Point) :boolean +toString(): String Create the class Point Implement the no-arg and all-arg constructors. Implement the calculateDistance method that returns the distance between two points. Implement the isEqual method that returns true if all coordinates are equal in both points and false otherwise. Implement the toString() method. If x=2.0. y=3.5, and z=4.0, then the method returns a string in the form: (2.0, 3.5, 4.0) Question 2: Create the class Sphere Implement the two constructors. The no-arg constructor should initialize the color to "black", the radius to 1.0, and the center to (0.0, 0.0, 0.0). Implement the getCenter method that returns the center of the sphere. Don't implement the rest of getters and setters. Implement the method calculateVolume() that returns the volume of the sphere. Volume = **AX radius Implement the isEqual method that returns true if both spheres have the same center and radius and false otherwise. Override the toString() method. The method returns a string in the form: Sphere(Radius:2.0, Center:(1.0, 2.0, 3.0), Color:RD, Volume:33.49333). Note that you should only display the first and last letters of the color capitalized. Part II: Write an application (driver program) for the classes in Part 1 Complete the application (driver class) TestSphere as requested below. Write code to perform the following operations: a) Create an array of 3 spheres. b) Ask the user to enter the radius, color, and center coordinates for these spheres: Create them. Store them inside the array. c) Print the information of all spheres (using the toString() method) d) Print the number of spheres with volume greater than 50. e) Print whether or not the first and last spheres are equal. f) Print the distance between the centers of the second and last spheres

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!