Write a Java program to check whether three given lengths (integers) of three sides form a right triangle
- برمجة جافا
- برمجة
- 2021-05-01
- razanmazen8711884270
الأجوبة
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
class Main {
Scanner sc = new Scanner(System.in);
public void run() {
System.out.println("Input three integers(sides of a triangle)");
int[] int_num = new int[]{
sc.nextInt(),sc.nextInt(),sc.nextInt()
};
Arrays.sort(int_num);
System.out.println("If the given sides form a right triangle?");
ln((int_num[2]*int_num[2]==int_num[0]*int_num[0]+int_num[1]*int_num[1])?"Yes":"No");
}
public static void main(String[] args) {
new Main().run();
}
public static void pr(Object o) {
System.out.print(o);
}
public static void ln(Object o) {
System.out.println(o);
}
public static void ln() {
System.out.println();
}
}
Sample Output:
Input three integers(sides of a triangle) 6 9 12 If the given sides form a right triangle? No
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال