2023-02-18 14:09:11 +00:00
|
|
|
package aula02;
|
|
|
|
|
2023-02-20 14:20:27 +00:00
|
|
|
// Código da package utils disponível em
|
|
|
|
// https://github.com/TiagoRG/uaveiro-leci/tree/master/1ano/2semestre/poo/src/utils
|
2023-02-18 14:09:11 +00:00
|
|
|
import utils.UserInput;
|
|
|
|
|
2023-02-17 23:33:57 +00:00
|
|
|
import java.util.Scanner;
|
|
|
|
|
|
|
|
// Solução do exercício 8
|
|
|
|
|
|
|
|
public class PythagoreanTheorem {
|
|
|
|
public static void main(String[] args){
|
|
|
|
Scanner sin = new Scanner(System.in);
|
|
|
|
|
|
|
|
System.out.println("Cateto A:");
|
2023-02-18 14:09:11 +00:00
|
|
|
double a = UserInput.getPositiveNumber(sin);
|
2023-02-17 23:33:57 +00:00
|
|
|
System.out.println("Cateto B:");
|
2023-02-18 14:09:11 +00:00
|
|
|
double b = UserInput.getPositiveNumber(sin);
|
2023-02-17 23:33:57 +00:00
|
|
|
|
|
|
|
double c = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2));
|
2023-02-20 10:14:11 +00:00
|
|
|
double angDeg = Math.acos(a / c) * 180 / Math.PI;
|
2023-02-17 23:33:57 +00:00
|
|
|
|
2023-02-20 10:14:11 +00:00
|
|
|
System.out.printf("O comprimento da hipotenusa é %.2f e o valor do angulo entre o cateto A e a hipotenusa é %.2f°", c, angDeg);
|
2023-02-17 23:33:57 +00:00
|
|
|
|
2023-02-20 10:14:11 +00:00
|
|
|
sin.close();
|
2023-02-17 23:33:57 +00:00
|
|
|
}
|
|
|
|
}
|