Problem: Areas of Figures
Write a program that inputs the sizes of a geometric figure and calculates its area. The figures are four types: square, rectangle, circle and triangle.
The first line of the input provides the type of the figure (square
, rectangle
, circle
, triangle
).
- If the figure is a square, the next line provides one number – the length of its side.
- If the figure is a rectangle, the next two lines we provide two numbers – the lengths of its sides.
- If the figure is a circle, the next line provides one number – the radius of the circle.
- If the figure is a triangle, the next two lines provide two numbers – the length of the side and the length of its height.
Round the result up to the third digit after the decimal point.
Sample Input and Output
Input | Output |
---|---|
square 5 |
25 |
rectangle 7 2.5 |
17.5 |
circle 6 |
113.097 |
triangle 4.5 20 |
45 |
Testing in the Judge System
Test your solution here: https://judge.softuni.org/Contests/Practice/Index/506#12.