| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Program help please!!!
i am suppossed to write a program to do the following "Using the ADT complex, write a program to determine the real roots of the quadratic equation, where a does not equal 0, after requesting the values of a, b, and c.
Note: The equation has 2 real roots if is positive, 1 real root if is zero, or 2 imaginary roots if is negative. The solutions are given by the quadratic formula:" here is the class we are supposed to use or modify slightly to do this program. class Complex { // complex number object public: Complex(); // default constructor Complex( double, double ); // constructor that initializes real, imag Complex( double ); // constructor that permits conversion // from real to Complex double getReal(); // accessor, returns the real part of a complex number object double getImag(); // accessor , returns the imaginary part of a complex number friend Complex operator + (const Complex &, const Complex &); //overloads the + operator to allow complex number object + complex number object friend Complex operator - (const Complex &, const Complex &); //overloads the - operator to allow complex number object += complex number object private: double real; //the real part of a complex number object double imag; //the imaginary part of a complex number object friend istream & operator >> ( istream&, Complex& ); //overloads the >> operator to allow cin >> complex number object friend ostream& operator << ( ostream&, const Complex& ); //overloads the << operator to allow cout << complex number object }; i'm really confused at how to start this program, my teacher spent one class period teaching classes and abstract data types, i have a final on it on monday, i'm screwwed for that but i would like to get this program done.. any help would be greatly appreciated!! |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Program help please!!! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|