In Java Eclipse, create a program Pythagoras which includes a method ‘double getC(double a, double b)’ which would find and return the length of the hypotenuse c given the length of the other sides a and b.
Formula: c= sqrt(a^2+b^2)
import java.util.Scanner;
public class Pythagoras {
public static void main(String[] args) {
Scanner in=new
Scanner(System.in);
//user input
System.out.println("Enter side a:
");
double a=in.nextDouble();
System.out.println("Enter side b:
");
double b=in.nextDouble();
System.out.println("length of the
hypotenuse is: "+getC(a,b));
}
public static double getC(double a, double b)
{
return Math.sqrt(Math.pow(a, 2) +
Math.pow(a, 2));
}
}
Get Answers For Free
Most questions answered within 1 hours.