Page 1 of 1

using System; public class Complex { 8: 81 8 private double rP; // real part private double iP; // imaginary part 3 refe

Posted: Sun Jul 03, 2022 11:59 am
by answerhappygod
Using System Public Class Complex 8 81 8 Private Double Rp Real Part Private Double Ip Imaginary Part 3 Refe 1
Using System Public Class Complex 8 81 8 Private Double Rp Real Part Private Double Ip Imaginary Part 3 Refe 1 (47.88 KiB) Viewed 18 times
Using System Public Class Complex 8 81 8 Private Double Rp Real Part Private Double Ip Imaginary Part 3 Refe 2
Using System Public Class Complex 8 81 8 Private Double Rp Real Part Private Double Ip Imaginary Part 3 Refe 2 (42.51 KiB) Viewed 18 times
Using System Public Class Complex 8 81 8 Private Double Rp Real Part Private Double Ip Imaginary Part 3 Refe 3
Using System Public Class Complex 8 81 8 Private Double Rp Real Part Private Double Ip Imaginary Part 3 Refe 3 (54.24 KiB) Viewed 18 times
Using System Public Class Complex 8 81 8 Private Double Rp Real Part Private Double Ip Imaginary Part 3 Refe 4
Using System Public Class Complex 8 81 8 Private Double Rp Real Part Private Double Ip Imaginary Part 3 Refe 4 (47.08 KiB) Viewed 18 times
using System; public class Complex { 8: 81 8 private double rP; // real part private double iP; // imaginary part 3 references public void Set Complex (double r, double i) { O references public void add(Complex c1) { } rp = r; iP = i; } rP += c1.rP; ip += cl. iP; O references public void add Two (Complex cl, Complex c2) { rP = cl.rp + c2.rp; iP cl.ip + c2.ip; 1 reference public void mul (Complex c1) { // use the formula (a+bj) (c+dj) = (ac-bd) + (ad+bc)j rP = rp iP = rp cl.rp - ip * cl.ip; cl.iP + iP cl.rP;
1 reference public void mulfix (Complex cl) { // use the formula (a+bj) (c+dj) = (ac-bd) Cad+bc)j Complex ccopy = new Complex(); ccopy.rP = TP ccopy.ip = IP rP = ccopy.rP: ip = ccopy.ip; 3 references public void print() { cl.rp - ip * cl.ip; cl.ip + ip * cl.rp; Console.WriteLine("{0} + {1}j", rP, ip);
using System; O references public class Complex Test { 8 O references public static void Main(string[] args) { // create and initialize a Complex object Complex c1 = new Complex (), c2 = new Complex (), c3 = new Complex(); Console.WriteLine("Create 1+j"); cl.Set Complex (1, 1); Console.WriteLine("Print that"); 1-j"); Console.WriteLine("Create c2. Set Complex (1, -1); Console.WriteLine(" (1+j) (1-j) in the wrong way (correct answer is 2)"); cl.mul (c2); cl.add(c2); cl.print(); cl.print(); Console.WriteLine(" (1+j) (1-j) in the right way (correct answer is 2)"); cl.Set Complex (1, 1); cl.mulfix(c2); cl.print(
4. (39%) Enhance class Complex from week 4 (that has add, mulfix, etc.) or class Complex from week 5 (that has +-* as operators) (a) (5%) Method subtract (or operator -) to subtract two complex numbers (b) (10%) Method div (or operator /) to divide one complex number by another complex number va²+b² (c) (14%) Note that polar form of a complex number a +bj=re" with r of c, and argument or angle 8 as arctan (b/a) (are tangent of b/a). as the magnitude or the value (7%) Define method CarToPolar that convert a complex number of the Cartesian form a +bj to the polar form re" (7%) Define a second method Polar ToCar to convert a complex number of the polar form-re to its Cartesian form a +bj Note ar cos 0, and b-r sin( 0). (d) (10%) Test your enhanced class Complex with such test data: C1-1+1,C2-1-1 Compute C1+C2, C1-C2, C1 C2 and C1/C2 (division), Compute the polar form of C1, C2, and c Compute C1/0 (division by zero) and show if you have error messages (Note for 1-1, 1-2 and 45 degrees or a/4.) Note square root can be implemented using sqrt, and arctangent is implemented using atan or atan2 library functions 2