Question: Write a class Area that has three overloaded static methods (called getArea as described below) for calculating the areas of the following geometric shapes.The name
Write a class Area that has three overloaded static methods (called getArea as described below) for calculating the areas of the following geometric shapes.The name of the project should be AreaClassDemo. Please make sure you include the definition of the class Area in the same file as AreaClassDemo.java
Circles (getArea method with one double parameter (radius) to compute the area of a circle)
Rectangles (getArea method with two integer parameters (length and width) to compute the area of a rectangle)
Cylinders (getArea method with two double parameters (radius and height) to compute the area of a cylinder)
Here are the formulas for calculating the area of the shapes:
Area of a circle: Area = r2 where is Math.PI and r is the circles radius
Area of a rectangle: Area = widthlength
Area of a cylinder: Area = r2 h where is Math.PI, r is the radius of the cylinders base, and h is the cylinders height
Because the three methods are to be overloaded, they should each have the same name, but different parameter lists. Demonstrate the class in a complete program.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
