” PIC 10B留学生程序 写作、C/C++程序PIC 10B Homework 4 Due Friday, Feb 26Problem 1:Using good coding practices, design your own ComplexVector class for vectors whose elementsare complex numbers. Provide an overloading implementation for term by termaddition, subtraction, multiplication, division, and the stream output operator. Such that ifv1 and v2 are ComplexVector objects, then one can compute v1 + v2, etc.Hint : you may want to create a Complex class separately.Complex numbers are expressed in the form a+bi, where a is the real part, b is the imaginarypart, and i is the imaginary unit satisfying i2 = 1. Print your complex Numbers using thisrepresentation. When adding (or subtracting) two complex numbers, add (or subtract) theirreal parts and imaginary parts separately. The multiplication of two complex numbers isdefined by,(a + bi)(c + di) = (ac bd) + (bc + ad)i, (1)while division is given by,a + biUsing your newly defined ComplexVector class, write a recursive function to print thefirst 6 terms in the sequence from equation (3) to a file titled ComplexSequence.txt.fn+1 =(2 + 3 i) n7 + 5 n2ifn, (3)f1 = 1 + i (4)Using the vectors v1 and v2 ,v1 = { 2 + 4 i, 3 + 5 i, -1 – 3 i , 8 + 10 i }v2 = { -10 + 3.5 i, 4 + 7.3 i, 2 – 8 i, 10 -142 i},write a main function that checks v1 + v2, v1 – v2, v1 * v2, and v1 / v2 by printingthem to the console. Figure 1 shows the sample outputs.Due Friday, Feb 26 Homework 4 PIC 10BFigure 1: Sample output.Good Coding Practices: think about cross-platform. Dont use Windows or Mac only commands. For example,pause == cin.get() twice, Write many \n vs. system(clear) or system(cls). passing objects by reference or const when possible using field initializer list when possible in all constructorsInstructions for submission: Name your files exactly hw4.cpp, Complex.h, Complex.cpp, ComplexVector.h, andComplexVector.cpp. You may not use #include stdafx.h. Add code description in the comment at the beginning of the file.A sample description may look like:/*PIC 10B 2A, Homework 1Purpose: Tic-tac-toe gameAuthor: Hanqin CaiDate: 10/10/2019*/ Submit your header Files and source codes to CCLE in separate files. Only .h and .cppfiles should be uploaded.如有需要,请加QQ:99515681 或WX:codehelp
“
添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导。