I want to replace the variables izquierda
and derecha
with user entries.
How could I do it?
public class Test {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
float calculos = 0.1f;
boolean control = true;
float x = 0;
while (control){
float margenDeError = 0.001f; // Margen de error
for (int i = 0 ; i < 2 ; i++){ // check
float izquierda = 2 + x; // Parte de la ecuacion
float derecha = x * x; // Parte de la ecuacion
float maxP = Math.max(Math.abs(izquierda), Math.abs(derecha));
float minP = Math.min(Math.abs(izquierda), Math.abs(derecha));
control = (maxP - minP > margenDeError);
System.out.println(x);
if (control && i == 0){
x = -x;
}else if (!control){
System.out.println(x);
break;
}else{
x = Math.abs(x);
x += calculos;
}
}
}
}
}