Lab 2 More Classes
Object Oriented Programming using C++
What you will learn
Implementing classes
File I/O
More operator overloading
Error checking
Coding exercise
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 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 demo Create a driver program that tests all the functionality in the 6 points above. Make sure to test for edge cases.NotesYou can look for help on the Internet but refrain from referencing too much. Please cite all your sources as comments in cmpe126-lab2.cpp.1 Introduction to complex numbers https://www.youtube.com/watch?v=SP-YJe7Vldo
Programming
[SOLVED] C++ Lab 2 More Classes
$25
File Name: C++_Lab_2__More_Classes.zip
File Size: 216.66 KB
Only logged in customers who have purchased this product may leave a review.
Reviews
There are no reviews yet.