-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArea.java
More file actions
28 lines (20 loc) · 896 Bytes
/
Area.java
File metadata and controls
28 lines (20 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.text.DecimalFormat;
import java.util.Scanner;
public class Area {
public static void main(String[] args) {
DecimalFormat formata = new DecimalFormat("0.000");
Scanner leitor = new Scanner(System.in);
double[] valores;
valores = new double[3];
double pi = 3.14159;
for (int x = 0; x < 3; x++) {
valores[x] = leitor.nextDouble();
}
leitor.close();
System.out.println("TRIANGULO: " + formata.format(valores[0]*valores[2]/2));
System.out.println("CIRCULO: " + formata.format(pi * Math.pow(valores[2],2)));
System.out.println("TRAPEZIO: " + formata.format( (valores[0] + valores[1]) * valores[2]/2));
System.out.println("QUADRADO: " + formata.format(Math.pow(valores[1], 2)));
System.out.println("RETANGULO: " + formata.format(valores[0] * valores[1]));
}
}