Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in java please In a package called shape, create a Sphere class and a Sphere Driver Class. Your Sphere Driver should demonstrate creating a Sphere

image text in transcribedin java please

In a package called shape, create a Sphere class and a Sphere Driver Class. Your Sphere Driver should demonstrate creating a Sphere object and using it to invoke the Sphere methods. Your Sphere class should have the following: Class variable diameter that has a private visibility A constructor without parameters that sets diameter to a default of 1 A setDiameter(int diameter) method that sets the parameter's diameter to the classes diameter (you must you this) A getDiameter() method that returns the diameter AgetVolume() method that return the volume of a sphere A getSurfaceArea() method that return the surface area of a sphere AtoString method that returns a string representation of the Sphere. You should round to the second decimal place. Ex: A sphere with a diameter of 4 has a volume of 33.51 and a surface area of 50.27 Submit you Sphere.java file for grading

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions