For the if discriminant < 0 statement, I need to not only display the error message, but I must display the complex roots in the correct format for complex numbers. How should I go about that? #include <iostream> #include <cmath> using std::cout; using std::cin; int main() { int a = 0, b = 0, c = 0, x1 = 0, x2 = 0, discriminant = 0; cout <<"Enter value for A: "; cin >> a; cout <<"Enter value for B: "; cin >> b; cout <<"Enter value for C: "; cin >> c; x1 = (-b + sqrt ((b * … |
+0 forum
2 | ||

[CODE]if (option == 3) { { pmt = (percentage * earnings); cout << "pmt is " << pmt << endl; wr = (0.06 / 52.0); cout << "wr is " << wr << endl; n = (52 * actualage); cout << "n is " << n << endl; retirement = pmt * ((1 + wr)n - 1) / wr); cout << "You will have $" << retirement << " saved when you retire." << endl; }[/CODE] |
+0 forum
1 | ||

Could someone give me help on how to simplify this? Trying to write code to solve this equation: Distance = sqrt((x2 - x1)^2 + (y2 - y1)^2 + (z2 - z1)^2) I subbed a,b,c as the second set of coords. Im probably using too many vars as weel but im new, give it some time. [code] void school(int x,int y,int z, int a,int b,int c); int main() {int a,b,c,x,y,z; cout<< "enter coordinates plz"<<endl; cin>>x>>y>>z>>a>>b>>c; school(x,y,z,a,b,c); return 0; } void school(int x,int y,int z,int a,int b,int c) {float d,e,f,g,h; d=x-a; e=y-b; f=z-c; g=powf(d,2)+powf(e,2)+powf(f,2); h=sqrtf(g); cout<<"the answer is "<<h; } [/code] |
+0 forum
6 |

The End.