Expand|Select|Wrap|Line Numbers
- #include <cmath>
- #include <iostream>
- using namespace std;
- int main()
- {
- double x;
- double y;
- double z;
- cout<<"Please enter the coeff of (x square):";
- cin>> x;
- cout<<"Please enter the coeff of (x):";
- cin>> y;
- cout<<"Please enter the number without the unknown (x):";
- cin>> z;
- double b = (((y * y) - (4 * x * z)));
- double a = ((-y + (sqrt (b)) / (2 * x)));
- double c = ((-y - (sqrt (b)) / (2 * x)));
- cout<<"X = "<< a << "or" << c;
- cin.ignore();
- cin.get();
- }
Please tell me what is wrong.. PLEASE PLEASE PLEASE
-------------------------------------------------------------------
This should help in understanding what i am trying to do.....
This program is supposed to solve equations like (3x^2 * -7x + 2)
so.. Using the general formula to solve this equation we take the coeff of x^2 to be "x", coeff of x to be "y" and coeff of number without unknown x to be "z".
Therefore x = 3
y = -7
z = 2
The equation to find x = ((-y) + sqrt((y^2) - (4*x*z))) / 2*x)
so... resulting to.. x = (7 + (sqrt (49 - 24)) / 6
and.. x = (7 + 5)/6
x = 2 //
As you can see.. in my code.. double b should = 25...
Any questions please ask.. i need help to solve this program.. I just really want to finish this program so please help