1. Write an algorithm and draw flowchart to accept three numbers (h, p, b) and
check whether they are “Pythagorean Triplet” or not.
Please give me a suitable answer for this question.
Answers
Answered by
0
Answer:
import java.util.Scanner;
public class Pythogoras
{
public static void main(String []args)
{
System.out.println("Write the base and height of the right angle trianlge");
Scanner sc = new Scanner(System.in);
int base =sc.nextInt();
int height =sc.nextInt();
double x= Math.pow(base,2)+Math.pow(height,2);
System.out.println("write the hypotenuse");
int hypotenuse =sc.nextInt();
double y= Math.pow(hypotenuse,2);
if (x==y)
{
System.out.println("They are pythogoras triplets");
}
else
System.out.println("ERROR");
}
}
Explanation:
You can replace the hypotenuse with highest number;
and base and height for the other two numbers
Similar questions