I have to create this program for class, a quadratic formula program that will output three results using an I/O file, "The roots are complex," "The roots are real," and "The formula has one real root." For the second output, I must output the roots. I get the proper result (the type), but I am not getting the proper roots.
>>"We are not allowed to use sqrt. The professor was like, "It is not in the codding prompt." Believe me, that would make my life easier. "
If you can't use the square root function, you are not using the Quadratic Formula. That doesn't make sense. I don't think it can be done without the square root function.
Also, a couple things caught my eye:
(i) you compute the discriminant, but then you don't use it on the next two lines, in the computation of TERMA and TERMB. Instead of writing all that out, you could have just used your value of discriminant.
(ii) I think you have an opening bracket in the wrong place. The 2a term in the denominator is supposed to divide everything; as it is now, it seems to be just dividing the second term.
I don't think it can be done without the square root function.
there are other ways to get the square root of a number. Also, you can simply raise to the power of .5 :P (same as square rooting without creating your own method like the Babylon method or some other).
BTW, you have changed the output from the assignment.
You say "The roots are repeated."
No they are not. There is only one root when the discriminant is zero. Hence, "The formula has one real root."
Also, go ask your professor what exactly he means by "it's not in the coding prompt." You cannot compute the quadratic formula without calculating the square root.
"there are other ways to get the square root of a number. Also, you can simply raise to the power of .5 :P (same as square rooting without creating your own method like the Babylon method or some other). "
True. One way or the other, you are computing the square root of the discriminant. I read the OP's post and understood it to mean the square root could not be computed, not just that particular function. I thought, how else to do it? Computers can't do it by inspection!?
In any case, I am glad to see it appears to have worked out for the OP.