With less code than this getHypo is reduced to a mere wrapper 
Code:
public class getHypo {
/*
private double a;
private double b;
the c you declare here is local to the getHypo class, the a and
b values are also local (and 0).
private double c = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2));
*/
double getC(double a, double b) {
return Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2));
}
}
public class pythagorian {
public static void main(String[] args) {
double a, b, c;
ConsoleIO console = new ConsoleIO();
getHypo **** = new getHypo();
System.out.print("a = ");
a = console.readDouble();
System.out.print("\nb = ");
b = console.readDouble();
System.out.print("\nc = ");
c = ****.getC();
System.out.println(c);
}
}
Bookmarks