Computer Science, asked by ranchodas7875, 11 months ago

Write a program to input three nos and check their pythagoras theoram

Answers

Answered by FlyingSaturn
0

Answer in Java (Procedural Oriented Programming):

import java.io.*;

class Pythagoras_Theorem

{// I am using BufferedReader class.

public static void main(String args[])

{

InputStreamReader read = new InputStreamReader(System.in);

BufferedReader input = new BufferedReader(read);

double p,b,h,h2,p2,b2,b2p2 = 0;

System.out.println("Enter the Hypotenuse");

String v1 = input.nextLine();

h = Double.parseDouble(v1);

System.out.println("Enter the Base");

String v2 = input.nextLine();

b = Double.parseDouble(v2);

System.out.println("Enter the Perpendicular");

String v3 = input.nextLine();

p = Double.parseDouble(v3);

h2 = Math.pow(h,2);

b2 = Math.pow(b,2);

p2 = Math.pow(p,2);

b2p2= b2 + p2;

if(h2 = b2p2)

System.out.println("Pythagoras Theorem applies");

else

System.out.println("Pythagoras Theorem does not apply");

}

}

Answered by sushiladevi4418
0

Answer:

Write a program to input three numbers and check their Pythagoras theorem.

Explanation:

Java Program

import java.util.*;

class pythagorean_triplet

{

Scanner sc = new Scanner(System.in);

int a,b,c;

System.Out.println("Enter the three numbers")

a=sc.nextInt()

b=sc.nextInt()

c=sc.nextInt()

if(a*a+b*b==c*c)

System.Out.println("Pythagorean Theorem")

else

System.Out.println("Not a Pythagorean Theorem")

}

}  

Output:-

Enter three numbers:-

3

4

5

Pythagorean Theorem

Similar questions