Interface for geometric shapes

Go Easy interfaces

Task «Interface for geometric shapes»

Create a Shape interface that contains the Area() float64 method. Implement the Circle (with a Radius float64 field) and Rectangle (with Width, Height float64 fields) structs that satisfy the Shape interface. Write a PrintArea(s Shape) function that prints the area of the shape with an accuracy of two decimal places. In main, read from stdin a string containing the shape type ('circle' or 'rectangle') and its parameters (radius for a circle, width and height for a rectangle). Call PrintArea for the corresponding shape.

Input Format

One line: first the word 'circle' or 'rectangle', then numbers (for circle — radius, for rectangle — width and height). All numbers are integers or floating-point.

Output Format

One number — the area of the figure, rounded to two decimal places.

Examples

Example 1

INPUT
circle 5
OUTPUT
78.54

Example 2

INPUT
7 ADD 1 handler1 ADD 1 handler2 FIRE 1 eventA ADD 2 handler3 FIRE 1 eventB REMOVE 1 handler1 FIRE 1 eventC
OUTPUT

Example 3

INPUT
rectangle 3 4
OUTPUT
12.00

Example 4

INPUT
5 ADD 5 procA ADD 5 procB FIRE 5 data1 REMOVE 5 procA FIRE 5 data2
OUTPUT

Example 5

INPUT
circle 0
OUTPUT
0.00
main.go