Floor-space of the room

Report a typo

Citizens of the country named Malevia often experiment with the shapes of their rooms. The rooms can be triangular, rectangular, and round.

Write a program that calculates the floor area of the rooms.

Input data format: The type of the room shape and the relevant parameters.

Output data format: The area of the resulting room.

Note that the value of 3.14 is used instead of the number π in Malevia.

Input format used by the Malevians:

triangle
a
b
c

where a, b, and c are lengths of the triangle sides.

rectangle
a
b

where a and b are lengths of the rectangle sides.

circle
r

where r is the radius of the circle.

Note that the input values (a, b, c, r) are doubles, and your answer should be too.

Sample Input 1:

rectangle
4
10

Sample Output 1:

40.0

Sample Input 2:

circle
5

Sample Output 2:

78.5

Sample Input 3:

triangle
3
3
3

Sample Output 3:

3.897114317029974
Write a program in Java 17
import java.util.Scanner;

class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// start coding here
}
}
___

Create a free account to access the full topic