Quadratic Equation Solving
public class Quadratic
{
public static void main(String args[])
{
double b, a, c, inSqr, total1, total2, toSqr; a = 5;
b = -7;
c = 2;
toSqr = (b*b)-(4*a*c); inSqr = Math.sqrt(toSqr);
total1 = ((-1*b)+inSqr)/(2*a);
total2 = ((-1*b)-inSqr)/(2*a);
System.out.println("\n\n\n\t\t\t::QUADRATIC EQUATION::");
System.out.println("Varibles");
System.out.println("\t-> a = "+a);
System.out.println("\t-> b = "+b);
System.out.println("\t-> c = "+c);
System.out.println("\n\nResult of Quadratic Equation [with +]: "+total1);
System.out.println(" ______________");
System.out.println("(-b)+/(b*b)-(4*a*c)");
System.out.println("-------------------- = "+total1);
System.out.println(" 2a ");
System.out.println("\n\nResult of Quadratic Equation [with -]: "+total2);
System.out.println(" ______________"); System.out.println("(-b)-/(b*b)-(4*a*c)");
System.out.println("-------------------- = "+total2); System.out.println(" 2a ");
System.out.println("\t\t\t***THE END***");
}
}
}
No comments:
Post a Comment