Hi,
I have the following class.
public class Hypotenuse
{
public double calcHypotenuse(double sideA, double sideB)
{
return (Math.sqrt(Math.pow (sideA, 2) + Math.pow (sideB, 2)));
}
public static void main (
String args[])
{
Hypotenuse hypot;
double sideA, sideB, sideC;
if (args.length < 2) { //Don't understand why it will print out the error message as I pass args[0] and args[1] only.
System.err.println(
"Usage:
java Hypotenuse <side a> <side b>");
System.exit(1);
}
sideA = Double.valueOf(args[0]).doubleValue(); //Will this assignment create a double value for sideA?
sideB = Double.valueOf(args[1]).doubleValue();
hypot = new Hypotenuse();
sideC = hypot.calcHypotenuse(sideA, sideB);
System.out.println(
"Given a triangle with two sides: " + sideA +
" and " + sideB + ", the longest side is: " + sideC);
//Why don't this result print out?
}
}
Thanks for help.
Andrew