Question: Lab 2 More Classes Object Oriented Programming using C++ 1. Create a class called complexNumber that stores a complex number of the form a+bi, where

Lab 2 More Classes Object Oriented Programming using C++

1. Create a class called complexNumber that stores a complex number of the form a+bi, where i is 1. a is the real and b is the imaginary part of the number1 . You should be able to get the real and imaginary parts of the number. a and b can be negative, e.g., 3+4i, -3+4i, 3-4i, and -3- 4i.

2. Implement the ability to add, subtract, and multiply two complexNumber objects and save the result in another complexNumber object by overloading operators +, -, and *.

3. Overload the operators >> and << to input and output string of the form a+bi from the complexNumber object respectively.

4. Read a file called complexInput.txt (sample input file attached) containing numbers of the form (a+bi) followed by an operator followed by another complex number of the form (a+ib).

5. Perform the operations on the numbers you read and store the result in a new complexNumber. Output the number in a new output file called complexOutput.txt (sample output file included).

6. [Bonus - optional] Implement error checking on the input and reject/ignore values that are not in the format a+bi. Log this information in the output file. A sample wrong input file called complexInputWrong.txt is attached. What to turn in A zip file containing the files cmpe126-lab2.cpp, complex.cpp and complex.h files

A file called Notes explaining your design Notes You can look for help on the Internet but refrain from referencing too much. Please cite all your sources as comments in cmpe126-lab2.cpp.

file:

complexInput.txt inside (3+4i) * (5-6i)

complexOutput.txt inside (39+2i)

complexInputWrong inside (3+4i) - dummy

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!