2023-02-18 14:09:11 +00:00
package aula02 ;
import utils.MathTools ;
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 ) ) ;
double cossin = a / c ;
double angRad = Math . acos ( cossin ) ;
double angDeg = angRad * 180 / Math . PI ;
2023-02-18 14:09:11 +00:00
System . out . printf ( " O comprimento da hipotenusa é %f e o valor do angulo entre o cateto A e a hipotenusa é %f° " , MathTools . round ( c , 2 ) , MathTools . round ( angDeg , 2 ) ) ;
2023-02-17 23:33:57 +00:00
}
}