Java Program to Check Whether Given Four Points Form Pythagorean Quadruple

bookmark

class Main
{
    public static void main(String[] args)
    {
        //length, breadth, height, diagonal value declared
        int l = 1;
        int b = 2;
        int h = 2;
        int d = 3;
        //find sum of (l*l)+(b*b)+(h*h)
        int sum = (l*l)+(b*b)+(h*h);
        //check the sum is equal to d*d or not
        if(sum == d*d)
            System.out.println("It is a Pythagorean quadruple");
        else
            System.out.println("It is not a Pythagorean quadruple");
    }
}

 


Output:

It is a Pythagorean quadruple