I'm a complete beginner so I signed up for an edx.com MOOC. I don't think the course is very active anymore so I figured I'd join up here to ask questions when needed. I'm in the process of solving the Quadratic Equation, and I'm not getting the correct results.
the IO is an imported file from the class instructor
Using the numbers a = 5, b = 6, and c = 1
I should get the output of -0.2 and -1.0
I get -0.2 and 0.14833147735478827
Any help?
double a; double b; double c; double d; double first_x; double second_x; IO.output("Enter a: "); a = IO.inputDouble( ); IO.output("Enter b: "); b = IO.inputDouble( ); IO.output("Enter c: "); c = IO.inputDouble( ); d = Math.pow(b,2); first_x = (-b + Math.sqrt(d - 4 * a * c)) / (2 * a); second_x = (-b + Math.sqrt(d + 4 * a * c)) / (2 * a); IO.outputln("First Solution for x = " + first_x); IO.outputln("Second Solution for x = " + second_x);