Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Must be in C# class complex learned in class: using System; // namespace containing ArgumentOutOfRangeException public class Complex { private double rP; // real part
Must be in C#
class complex learned in class:
using System; // namespace containing ArgumentOutOfRangeException
public class Complex
{
private double rP; // real part
private double iP; // imaginary part
public void SetComplex(double r, double i)
{
rP = r;
iP = i;
}
public void add(Complex c1)
{
rP += c1.rP;
iP += c1.iP;
}
public void addTwo(Complex c1, Complex c2)
{
rP = c1.rP + c2.rP;
iP = c1.iP + c2.iP;
}
public void mul(Complex c1)
{
// use the formula (a+bj) * (c+dj) = (ac-bd) + (ad+bc)j
rP = rP * c1.rP - iP * c1.iP;
iP = rP * c1.iP + iP * c1.rP;
}
public void mulfix (Complex c1)
{
// use the formula (a+bj) * (c+dj) = (ac-bd) + (ad+bc)j
Complex ccopy = new Complex();
ccopy.rP = rP * c1.rP - iP * c1.iP;
ccopy.iP = rP * c1.iP + iP * c1.rP;
rP = ccopy.rP;
iP = ccopy.iP;
}
public void print()
{
Console.WriteLine("{0} + {1}j", rP, iP);
}
}
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