Question: +Automatic Zoom Design and implement 2 classes called Sphere and Cylinder that both have 2 instant variable that represents the radius, and an ID, and
+Automatic Zoom Design and implement 2 classes called Sphere and Cylinder that both have 2 instant variable that represents the radius, and an ID, and the cylinder class have one more instant variable that represents its height All the instant variables should enforce the encapsulation (the visibility should be private). In both classes there is no need to have setter(Mutator) method but they should have getter(accessor) to access the ID and the radius. Both classes should have these methods as well Volume calculates the volume of the shape Area calculates the surface area of the shape toString- generate this string ("The id Sphere/cylinder with radius of radius") Then in driver class instantiate 5 sphere and 5 cylinder (whit "for" statement), in constructor create an ID for them like SO, S1, S2, S3, $4 for 5 spheres, CO, C1, C2, C3, C4 for 5 cylinders. For radius generate random double numbers between 0 and 10 and for the height of cylinder put 5.0. Round all the double numbers including the radius, height, area and volume to a double number with 2 points decimal. Then find and print the area and volume of them. Your output should be something in as the following lines: Sample output: The 58 Sphere with radius of 4.87, the surface area of 298.04 and the volume of 362.86 The S1 Sphere with radius of 4.51, the surface area of 255.6 and the volume of 288.19 The S2 Sphere with radius of 2.6, the surface area of 84.95 and the volume of s5.22 The S3 Sphere with radi The S4 Sphere with radius of 6.28, the surface area of 495.6 and t us of 5.12, the surface area of 329.42 and the volume of 421.66 he volume of 778.89 The Se Cylinder with radlus of 8.79, the surface area of 761.61 and the volume of 1213.66 The 51 Cylinder with radi The 52 Cylinder with radius of e.34, the surface area of 11.41 and the volume of 1 The 53 Cylinder with radius of 4.99, the surface area of 313.22 and the volume of 391.13 The SA Cylinder with radius us of 9.11, the surface area of 807.65 and the volume of 1303.64 Mathematics hints: volume of the sphere: ra a Surface area of the sphere: A-4r2 fresh, Ske-new esperiencel And by the way, welcome back
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
