Triangle
Submit solution
Points:
10
Time limit:
5.0s
Memory limit:
256M
Author:
Problem type
Allowed languages
C#, Go, Java, Python
Implementa el mètodes de la classe Triangle
.
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
class Triangle {
float base, height;
}
public class Solution {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Triangle t1 = new Triangle();
Triangle t2 = new Triangle();
t1.base = scanner.nextFloat();
t1.height = scanner.nextFloat();
System.out.format("Area triangle1: %.2f%n", t1.calculateArea());
t2.base = scanner.nextFloat();
t2.height = scanner.nextFloat();
System.out.format("Area triangle2: %.2f%n", t2.calculateArea());
}
}
Input Format
-
Constraints
-
Output Format
-
Sample Input 0
3 4
2 5
Sample Output 0
Area triangle1: 6.00
Area triangle2: 5.00
Sample Input 1
30.77 23.5
22.9 5.1
Sample Output 1
Area triangle1: 361.55
Area triangle2: 58.39
Sample Input 2
0 89
103 0
Sample Output 2
Area triangle1: 0.00
Area triangle2: 0.00
Autoria: Gerard Falcó
CC BY-NC-SA 4.0