In mathematics, the Pythagorean theorem, or Pythagoras' theorem, is a fundamental relation in Euclidean geometry among the three sides of a right triangle. It states that the area of the square whose side is the hypotenuse (the side opposite the right angle) is equal to the sum of the areas of the squares on the other two sides. This theorem can be written as an equation relating the lengths of the sides a, b and c, often called the Pythagorean equation:
where c represents the length of the hypotenuse and a and b are the lengths of the triangle's other two sides. The theorem, whose history is the subject of much debate, is named for the Greek philosopher Pythagoras, born around 570 BC.
The theorem has been proven numerous times by many different methods - possibly the most for any mathematical theorem. The proofs are diverse, including both geometric proofs and algebraic proofs, with some dating back thousands of years.
The theorem can be generalized in various ways: to higher-dimensional spaces, to spaces that are not Euclidean, to objects that are not right triangles, and to objects that are not triangles at all but n-dimensional solids. The Pythagorean theorem has attracted interest outside mathematics as a symbol of mathematical abstruseness, mystique, or intellectual power; popular references in literature, plays, musicals, songs, stamps, and cartoons abound.
The code for this problem is:
import java.util.Scanner;
public class pythagorasTheorem {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter the length of longest side of the triangle: ");
double h = scanner.nextDouble();
System.out.println("Enter the length of second side of the triangle: ");
double a = scanner.nextDouble();
System.out.println("Enter the length of third side of the triangle: ");
double b = scanner.nextDouble();
if ((h * h) == (a * a) + (b * b)) {
System.out.println("This is a right angled triangle.");
}
else {
System.out.println("This is not a right angled triangle.");
}
}
}
No comments:
Post a Comment