Question: JAVA Write a program with twice overloaded static method called area which returns a double value. the method should be in a class called CalcArea.

JAVA

Write a program with twice overloaded static method called area which returns a double value. the method should be in a class called CalcArea. The first overload takes in 2 double arguments (double width, double length) and returns the area of a rectangle, area = width*length; the 2nd overlaod takes only 1 double argumnet (double radius) and returns the area of a circle are = pi * radius * radius where pi = 3.1415.

Call the method twice, once to caculate the area of a rectangle 3.0 x 4.0 and once to calculate the area of a circle whose radius is 3.0 units.

Use printf to format output to 2 places after decimal point. Print output such as "the area of the rectangle is: " and "The area of the circle is: "

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!