For my programming class, I am required to loop prompts for user input for the following equation:
x= -3b plus or minus sqrt of (650-7c^2)(end sqrt)/ a-4c
I need to prompt the user for a. If the user enters -999, the program must terminate without prompting for b and c.
If the user doesn't enter -999, i need to prompt for b and c on seperate lines and then print both values of x.
Other conditions are:
clear the screen at the beginning off the run
display two results properly labeled or a descriptive error message if the input is invalid (such as a negative in a sqrt and dividing by zero)
and repeat until -999 is entered for a.
use double instead of float for most math. float has a terribly small number of bits for precision and suffers a lot of problems in complicated math (its ok here, but best practice going forward is use double).
the math function variable =s qrt(x); will be needed. Multiply is * ^ is the logical XOR command (exclusive or)(don't worry about this right now). pow(n, power) is the cmath power function BUT it is better to just multiply for small powers (N*N is better than pow(N,2)).
exit (0) is used for failures as an emergency stop all processing command. Use return (0) here.
it looks good so far, now you just need to do something like
double tmp = (b*b - 4*a*c);
if(tmp < 0)
...something else
tmp = sqrt(tmp);
and similar statements that cook up the answer, checking for problems along the way...
you have a solid start, keep at it and ask if you get stuck.
This is what i have for this assignment, but it isn't working, no matter how i follow the solution above. I enter a b and c, but nothing is displayed after it. can anyone help?