Question
NEED SOLUTION FAST! WILL GIVE GOOD RATING! THANKS! IN JAVA Write a small program that will calculate the volume of bodies. Write a Class Body.
NEED SOLUTION FAST! WILL GIVE GOOD RATING! THANKS!
IN JAVA
Write a small program that will calculate the volume of bodies.
Write a Class Body. That class should have double attribute volume.
Then write three sub-classes from Body: Sphere, Cylinder, and Cube.
The sub-classes should have the required attributes to calculate the respective areas:
Sphere has a double attribute radius, Cylinder has a double attribute height and radius, and Cube has a double attribute side.
In the main program, ask the user which body they want to calculate:1,2, or 3, for Sphere, Cylinder, and Cube. Based on the input, ask for the attribute required to calculate the volumes.
Once the user has entered the required information, output the volume of the body, and ask the user if they want to calculate another volume.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started