Interface for calculating the area of a figure
Java
Easy
interfaces
Task «Interface for calculating the area of a figure»
Create a Shape interface with a method double getArea(). Implement it in the Circle (radius) and Rectangle (width and height) classes. In main, read three numbers: the radius of the circle, the width and height of the rectangle. Output the area of the circle and the rectangle, each on a new line, with an accuracy of two decimal places.
Input Format
Three numbers separated by spaces: the radius of the circle, the width of the rectangle, the height of the rectangle. All numbers are integers or real numbers.
Output Format
Two strings: the first is the area of a circle, the second is the area of a rectangle. Each number with two decimal places.
Examples
Example 1
INPUT
1 2 3
OUTPUT
3.14
6.00
main.java