Here is the translation of the programming task text from Russian to English: Trait for calculating the area of shapes
Rust
Easy
traits
Task «Here is the translation of the programming task text from Russian to English: Trait for calculating the area of shapes»
Implement the Area trait with an area method that returns the area of a shape as f64. Define the structures Circle (radius) and Rectangle (width, height). Implement Area for them. In main, read three numbers from stdin: the radius of the circle, the width and height of the rectangle. Create objects and output the areas separated by a space with a precision of two decimal places.
Input Format
Three numbers separated by spaces: radius of the circle (f64), width of the rectangle (f64), height of the rectangle (f64).
Output Format
Two floating-point numbers, rounded to two decimal places: the area of the circle and the area of the rectangle, separated by a space.
Examples
Example 1
INPUT
5.0 4.0 3.0
OUTPUT
78.54 12.00
Example 2
INPUT
5
1 100.50 Food
2 250.00 Transport
3 75.25 food
4 300.00 Entertainment
5 45.00 transport
OUTPUT
Example 3
INPUT
0.0 10.0 10.0
OUTPUT
0.00 100.00
Example 4
INPUT
3
1 50.00 A
2 30.00 B
3 20.00 A
OUTPUT
main.rs