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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started