A beautiful Pythagorean Triple Program
For Java tutorials click the linkhttps://wordpress-343193-1101484.cloudwaysapps.com/wrapper-classes-in-java
A Pythagorean Triple is a set of positive integers, a, b and c that fits the rule: a^2 + b^2 = c^2
So if the three numbers are 3, 4, and 5.
3^2 + 4^2 = 5^2
9 + 16 = 25
so it is a Pythagorean Triple
For Java tutorials click the link
Wrapper classes in JAVA
Write a program to check if the given numbers are Pythagorean triplets or not.
import java.io.*;
class pythagoras
{
public static void main()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the base");
int base=Integer.parseInt(br.readLine());
System.out.println("Enter the height");
int height=Integer.parseInt(br.readLine());
System.out.println("Enter the hypotenuse");
int hypo=Integer.parseInt(br.readLine());
if(hypo*hypo==base*base+height*height)
{
System.out.println("A Pythagorean Triple");
}
else
{
System.out.println("Not a Pythagorean Triple");
}
}
}Output:
Enter the base
2
Enter the height
4
Enter the hypotenuse
5
Not a Pythagorean Triple
For core java tutorial click
https://www.youtube.com/user/trushnatej
Related Posts
Continue learning with these related articles

String Methods in Java for ICSE Class 10: 25 Output Questions with Answers
ICSE Class 10 Computer Applications practice on String class methods: length, charAt, indexOf, lastIndexOf, substring, replace, trim, compareTo, equals and more, with 25 board-style output questions and step-by-step answers.

Special Number Programs in Java for ICSE: Armstrong, Spy, Neon, Disarium, Pronic and More
Every special number asked in ICSE Computer Applications – prime, perfect, Armstrong, palindrome, automorphic, neon, spy, Niven, duck, buzz, Disarium, special and pronic numbers – with definitions, examples and one complete Java program that checks them all.

Math Library Methods in Java for ICSE Class 9 (with Outputs)
ICSE Class 9 Computer Applications notes on the Java Math class: sqrt, cbrt, pow, abs, max, min, ceil, floor, round, rint and random, with return types, tricky negative-number outputs and Java expressions for formulas.