-
Lenguaje
Java usando Scanner
-
Descripción
Se tiene un triángulo rectángulo. Obtenga e imprima la hipotenusa al recibir como datos el cateto adyacente y el ángulo en grados.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import java.util.Scanner;
public class HipotenusaAPartirDeCatetoAdyacenteYAngulo {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double cateto_adyacente, grados, hipotenusa;
System.out.print("Ingresa el valor de cateto adyacente: ");
cateto_adyacente = in.nextDouble();
in.nextLine();
System.out.print("Ingresa el valor de grados: ");
grados = in.nextDouble();
in.nextLine();
hipotenusa=cateto_adyacente/Math.cos(grados*Math.PI/180);
System.out.println("Valor de hipotenusa: " + hipotenusa);
}
}
public class HipotenusaAPartirDeCatetoAdyacenteYAngulo {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double cateto_adyacente, grados, hipotenusa;
System.out.print("Ingresa el valor de cateto adyacente: ");
cateto_adyacente = in.nextDouble();
in.nextLine();
System.out.print("Ingresa el valor de grados: ");
grados = in.nextDouble();
in.nextLine();
hipotenusa=cateto_adyacente/Math.cos(grados*Math.PI/180);
System.out.println("Valor de hipotenusa: " + hipotenusa);
}
}