import java.lang.*;
import java.util.*;
public class Ecuacionseg
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int a,b,c;
double x1=0,x2=0,d=0;
System.out.println("Teclea el valor de a" + "\t");
a=sc.nextInt();
System.out.println("Teclea el valor de b" + "\t");
b=sc.nextInt();
System.out.println("Teclea el valor de c \t");
c=sc.nextInt();
d=(b*b)-(4*a*c);
if (d > 0)
{
x1=(-b+Math.sqrt(d))/(2*a);
x2=(-b-Math.sqrt(d))/(2*a);
System.out.println("x1 = " + x1 + " x2 = " + x2);
} // true d >0
else
{
if ( d == 0)
{
x1=-b/(2*a);
x2 = x1;
System.out.println("x1 es igual a X2 " + x1);
} //true d = 0
else
{
System.out.println("raices imaginarias");
} //false d = 0
} // false d > 0
} // del main
} // de la clase
2 Responses
Write a comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.