Buenas,
Aqui tienes un constructor que hace exactamente lo que pides:
Código Java:
Ver originalpublic class Formula {
private final double a;
private final double b;
private final double c;
public Formula(double a, double b) {
this.a = a;
this.b = b;
this.
c = (a
*Math.
pow(b,
2))/(2*a
); }
public double getC() {
return this.c;
}
//Test
public static void main
(String...
args) { System.
out.
println(new Formula
(2,
4).
getC()); }
}
Un saludo