4
public class Equacao2Grau {
int a, b, c;
public int CalculoDelta(){
return (int) (Math.pow(b, 2) - 4*a*c);
}
public int FormulaQuadratica(){
int x1 = (int) (-b + Math.sqrt(CalculoDelta()) / 2*a);
int x2 = (int) (-b - Math.sqrt(CalculoDelta()) / 2*a);
return x1, x2;
}
public String exibeResultado(){
return "X1 = " + this.FormulaQuadratica() + "\nX2 = " + this.FormulaQuadratica();
}
}
pq does not return an array/list or even an object?
– rray
Face Concatenates the returns separated by ; and then removes by possibilities public int Formulaquadratica(){ int X1 = (int) (-b + Math.sqrt(Calculodelta()) / 2a); int x2 = (int) (-b - Math.sqrt(Calculodelta()) / 2a); String return = X1 + ";" + x2; return Return; } After a Split(';') and display the variable position[1]
– Renan Silveira
@Renansilveira has no need of it. If so it is better to return a
array
.– Sorack
A tuple,
javafx.util.Pair
, can resolve. You can create a type with propertiesx1
andx2
also.– vinibrsl