Robert X.

asked • 08/04/21

Help with Java Q

Write a program with twice overloaded static method called area which returns a double value. The method should be in a separate class called CalcArea. The first overload takes in two double arguments (double width, double length) and returns the area of a rectangle area= width x length; the second overload takes only one double argument (double radius) and returns the area of a circle area = pi*radius*radius where pi = 3.1415

Call the method twice from the main class (call main class CalcAreaTest) once to calculate area of rectangle 3.0 x 4.0 and once to calculate area of circle whose radius is 3.0 units.

Use printf to format output to 2 places after decimal point

Print appropriate out put such as

The area of the rectangle is ......

The area of the circle is ...

Hint: for static method in a separate class you need to use class name such as CalcArea.area(....)

1 Expert Answer

By:

Patrick B. answered • 08/04/21

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.