I try to run this program but I don't can.


write a Java Program that calculates the length of a hypotenuse of a right
triangle.the method should take two arguments of the double and return the hypotenuse as double.

import java.io.*;

public class Hypotenuse
{

public static void main(String[] args)
{
double hypotenuse;
double length;
String side1;
String side2;


/** @attribute System.STAThread() */
public static void main(String[] args)
throws java.io.IOException

{
InputStreamReader isr = new InputStreamReader(System.in);

BufferedReader input = new BufferedReader(isr);
double result
System.out.print("Enter the first side of the triangle: ");
String side1 = input.readLine();
double side1 = Double.parseDouble(side1);
System.out.println();

double result;
System.out.print("Enter the second side of the triangle: ");


String side2 = input.readLine();
double side2 = Double.parseDouble(side2);
System.out.print();

//
// TODO: Add code to start application here
//
}

result = hypotenuse ( side1, side2 );
System.Out.println("Hypotenuse of your triangle is: " + result );
return 0;

}
}

I don't see any hypotenuse ( side1, side2 ); method. Also, why do you have to main methods?

import java.io.*;

public class Triangle
{

   public Triangle()
   {
       super();
   }
   public double rounded_hypotenuse(double side_a, double side_b)
   {
       //compute
   }

   public static void main(String[] args)
   {
       //get input
      //parse to double
      //call method
     //print
   }
}

Use that as a starting point.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.