package ejercicio24;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class EJERCICIO24 {
public static void main(String[] args) throws IOException {
double a,b,c,d,x1,x2;
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
System.out.println("a: ");
a=(double) Integer.parseInt(in.readLine());//ojo
System.out.println("b: ");
b=(double)Integer.parseInt(in.readLine());//ojo
System.out.println("c: ");
c=(double) Integer.parseInt(in.readLine());//ojo
d=Math.pow(b,2.0)-4.0*c;
if(a!=0 && d>=0)
{
x1=(-b+Math.pow(d,(1.0/2.0)))/2*a;
x2=(-b-Math.pow(d,(1.0/2.0)))/2*a;
}
else
{
x1=0;
x2=0;
}
System.out.println("");
System.out.println("x1:" + x1);
System.out.println("x2:" + x2);
System.out.println();
}
}
No hay comentarios:
Publicar un comentario