Ramirez Albarran Omar escom ipn 6SCV2

Site hosted by Angelfire.com: Build your free website today!

Ecuacion

package MisClases;
import java.io.*;
public class Leer
{
public static String dato()
{
String sdato="";
try
{
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader flujoE = new BufferedReader(isr);
sdato= flujoE.readLine();
}
catch (IOException e)
{
System.err.println("Error: "+ e.getMessage());
}
return sdato;
}
public static int datoInt()
{
return Integer.parseInt(dato());
}

}

 

 

import MisClases.*;
import java.math.*;

public class Ecua
{
public static void main(String args[])
{
int a,b,c;
System.out.println("Inserte los elementos");
a=Leer.datoInt();
b=Leer.datoInt();
c=Leer.datoInt();


double raiz,sol,sol2;
raiz=(b*b-4*a*c);
if (raiz<0) {raiz=raiz*-1;}
raiz=Math.sqrt(raiz);
sol=(-b+raiz)/(2*a);
sol2=(-b-raiz)/(2*a);
System.out.println("La solucion 1 es: " + sol);
System.out.println("La solucion 2 es: " + sol2);



}
}