I try to run 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;


}
}

Recommended Answers

All 2 Replies

Member Avatar for iamthwee

You have two public static void mains. NO no no...!

You using buffered input from the command line. Since that is non-standard it's hard to tell if there might be a problem there?

Also, where oh where, is your actual calculation for the length of the hypotenuse. Hmm? There should be a squareroot sumwhere...

God bless.

:cool:

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.