//File : driverComplex.cpp //Author : Andre Long //Due : September 27, 2004 //Description : This application demonstrights the use of the complex class #include #include #include"lab3Header.h" using namespace std; int menu(); int main() { cout<<"Welcome to Andre's Complex number machine"<<"\n"; cout<<"Please make a menu selection"<<"\n"; complex num1; complex num2; complex result; float realNum; float xReal; float yImaginary; int choice; do { choice = menu(); switch(choice) { case 0:cout<<"Exiting Program have a nice day"<<"\n"; exit(0); break; case 1:cout<<"You may input both the X and Y componets with space"<<"\n"; cout<<"\n"; cout<<"First complex number "; num1.read(xReal, yImaginary); cout<<"\n"; cout<<"Second complex number "; num2.read(xReal, yImaginary); result.add(num1,num2); cout<<"\n"; cout<<"Complex Num1 + Complex Num2 = "; result.write(); cout<<"\n"; break; case 2:cout<<"You may input both the X and Y componets with space"<<"\n"; cout<<"\n"; cout<<"First complex number "; num1.read(xReal, yImaginary); cout<<"\n"; cout<<"Second complex number "; num2.read(xReal, yImaginary); result.subtract(num1,num2); cout<<"\n"; cout<<"Complex Num1 - Complex Num2 = "; result.write(); cout<<"\n"; break; case 3:cout<<"You may input both the X and Y componets with space"<<"\n"; cout<<"\n"; cout<<"First complex number "; num1.read(xReal, yImaginary); cout<<"\n"; cout<<"Second complex number "; num2.read(xReal, yImaginary); result.multiply(num1,num2); cout<<"\n"; cout<<"Complex Num1 * Complex Num2 = "; result.write(); cout<<"\n"; break; case 4:cout<<"Real number which multiplies the complex number "; cin>>realNum; cout<<"\n"; cout<<"Now the complex number "; num1.read(xReal, yImaginary); result.multiply(realNum, num1); cout<<"\n"; cout<<"Real Number * complex Num1 = "; result.write(); cout<<"\n"; break; } } while(choice <0 || choice >4 || choice==1 || choice==2 || choice==3 || choice==4); cout<<"\n"; cout<<"Thank You for trying my machine!"<<"\n"; } int menu() { int choice; cout<<"Your choices are: "<<"\n"; cout<<"\n"; cout<<" 0: Quit this program"<<"\n"; cout<<" 1: Add two complex numbers"<<"\n"; cout<<" 2: Subtract two complex numbers"<<"\n"; cout<<" 3: Multiply two complex numbers"<<"\n"; cout<<" 4: Multiply a real number with a complex number"<<"\n"; cout<<"\n"; cout<<"Enter your choice now "; cin>>choice; return choice; }