Meant to be written in Java JDK 14.0
Three double variables a, b, and c represent the length of 3 sides of a triangle. Write a program to determine if the triangle is right triangle. Find the hypotenuse side first.
import java.util.Scanner; public class CheckRightTriangle { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter lengths of three sides of a triangle: "); double a = in.nextDouble(); double b = in.nextDouble(); double c = in.nextDouble(); if (a*a == b*b + c*c || b*b == a*a + c*c || c*c == a*a + b*b) { System.out.println("This triangle is a right triangle"); } else { System.out.println("This triangle is not a right triangle"); } } }
Get Answers For Free
Most questions answered within 1 hours.