System.out.println("Finding the solution to ax^2+bx+c=0");
System.out.println("Write a value for a");
double a = input.nextDouble();
System.out.println("Write a value for b");
double b = input.nextDouble();
System.out.println("Write a value for c");
double c = input.nextDouble();
double square = (Math.sqrt(b*b-4*a*c));
double x1 = (-b+square)/(2*a);
double x2 = (-b-square)/(2*a);
double xx1 = (-b+square);
double xx2 = (-b-square);
if (square > 0)
{
System.out.println("x1= " +x1+ " and x2= "+x2);
}
else
{
System.out.println("Square root is 0 making x1 and x2 =" +-b/2*a);
}
if (a>0)
{
System.out.println("x1 = "+x1+ " and x2 = "+x2);
}
else {
System.out.println("x1 = "+xx1+ " and x2 = "+xx2);
}
}
}