##### Write a complex number class in java

*label*Programming

*account_circle*Unassigned

*schedule*0 Hours

*account_balance_wallet*$5

Write a complex number class. It will have a default constructor, explicit constructor, and the following methods: read() public Complex add(Complex), public Complex subtract(Complex), public Complex multiply(Complex), public Complex divide(Complex), public boolean equals(comlpex) and a toString( method. Include get and set methods as well. Your class should have at least 2 constructors: a default constructor, and an explicit constructor with two arguments of type double.

Please send me a message if you can do this, our professor said this is a really hard problem. So for you pros out there it will probably take like 20 mins.

Here is a demo program that shows what the output should look like and more info about the arithmetic of complex numbers

public class ComplexNumberDemo

{

public static void main (String[] args)

{

ComplexNumber cn1 = new ComplexNumber (4, 5);

ComplexNumber cn2 = new ComplexNumber (3, -2);

ComplexNumber cn3, cn4, cn5, cn6, cn7;

System.out.println ("First ComplexNumber number: " + cn1);

System.out.println ("Second ComplexNumber number: " + cn2);

if (cn1.equals(cn2))

System.out.println ("cn1 and cn2 are equal.");

else

System.out.println ("cn1 and cn2 are NOT equal.");

cn4 = cn1.add(cn2);

cn5 = cn1.subtract(cn2);

cn6 = cn1.multiply(cn2);

cn7 = cn1.divide(cn2);

System.out.println ("cn1 + cn2: " + cn4);

System.out.println ("cn1 - cn2: " + cn5);

System.out.println ("cn1 * cn2: " + cn6);

System.out.println ("cn1 / cn2: " + cn7);

}

}

/*

Here are some examples to test your program:

If c1 = 4 + 5i and c2 = 3 -2i then

the sum of c1 and c2 is 7.0 + 3.0i

subtracting c2 from c1 is 1.0 + 7.0i

multiplying c1 and c2 is 22.0 + 7.0i

dividing c1 by c2 is 0.1538461538 + 1.7692307692i

Complex (Imaginary) Number Arithmetic

Complex Numbers are represented by a “real part”, and an

“imaginary part”. The imaginary part is not real because it

is multiplied by √(-1). The √(-1) is represented by the

letter „i‟.

A complex number is written in the form:

(a + b*i)

(a)= the real part

(b)= the imaginary part

(i)= √(-1)

In this document we will write the second imaginary number

as:

(c + d*i)

(c)= the real part

(d)= the imaginary part

(i)= √(-1)

In a complex number class the real and imaginary parts are

stored as double‟s, and (i) is not stored because it‟s just

assumed that the imaginary part is multiplied by √(-1).

When you print out the imaginary number you can output “i”

or something like that after the imaginary part to signify

that it‟s the imaginary part.

Here are some examples of imaginary numbers so you can see

what is the real part and imaginary part.

(1) 1.5+3.2i, real_part=1.5, imaginary_part=3.2

(2) -15, real_part=-15, imaginary_part=0

this is a real number, so to represent it in

complex form, it‟s -15+0i

(3) -8.99i, real_part=0, imaginary_part=-8.99

(this is a complex number with no real part, so

it could be written as: 0-8.99i

(4) -6.2-14.3i, real_part=-6.2, imaginary_part=-14.3

Now that you know how complex numbers break down into two

floating-point number for the real part and the complex

part, we can use the (a)+(b)i notation to demonstrate the

arithmetic that a complex number class should do.Addition:

(a + b*i)+(c + d*i)=(a+c)+(b+d)i

result: real_part=(a+c), imaginary_part=(b+d)

Subtraction:

(a + b*i)-(c + d*i)=(a-c)+(b-d)i

result: real_part=(a-c), imaginary_part=(b-d)

Multiplication:

(a + b*i)*(c + d*i)=(a*c-b*d)+(a*d+b*c)i

result: real_part=(a*c-b*d), imaginary_part=(a*d+b*c)

Division:

(a + b*i)/(c + d*i)

= ((a*c+b*d)/(c2+d2)) + ((b*c-a*d)/(c2+d2))i

result: real_part=((a*c+b*d)/(c2+d2))

imaginary_part=((b*c-a*d)/(c2+d2))

Equality:

(a + b*i) = (c + d*i) if a=c, and b=d

Greater than, and less than do not make sense with complex

numbers because the real part could be greater, and the

imaginary part could be less or vice-versa.

Here are some examples to test your program:

If c1 = 4 + 5i and c2 = 3 -2i then

the sum of c1 and c2 is 7.0 + 3.0i

subtracting c2 from c1 is 1.0 + 7.0i

multiplying c1 and c2 is 22.0 + 7.0i

dividing c1 by c2 is 0.1538461538 + 1.7692307692i

I have 2+ years Experience in all software Technologies and Business World.

Apart from my professional, I am good in writing articles, and sports.

Your topic best suited for me, I can do it and I guarantee 1005 genuine work.

Let Me Try and I will Never be Let You Down.

Well can you do this problem than?

i can do it for $10.

Reply me if you are agree.

Sorry mate this is my first question 1$ for now. Need to make sure i don't get scam.If you do this than i will have two more questions for you and pay 25$for them.

25$ each ???

no 25 for three questions including this one.

Sorry Bro,i can't do this.

Next time .

Thanks

Why what happened? Why can't you do this?

Money, I need 10$ for this, next two question charged according to questions.

i will give you a paypal code that will add 25$ in your acc. So i can't pay you in 10$ sorry.

You see i need to know taht you are qualified to this problem or else you won't be able to the other two

it's OK . i can't do this i charges separately for all questions depends on question.

Ok how about i give you the other two problems too. You work on solution for all three of these problems. After that we will use a software called teamviewer. This software will allow me to see your screen but you will have complete control of your comp. Than you will run the three codes and i will look at the putput. If that'sthe output i want. Than i will pay you 25$. You can have the screen with code minimized so i can't see it and just run it. If they work the way i want them too than you get the money first before sending me the codes. This way i wall make sure that neither of us are scamming?

yea good idea but please can you make 35$ for all three problems,i am doing this because i want long term deal with you as like my other student who is from computer background .Hope you like it.

i can buy another 10$ card but that will take me like two weeks from now. As of 25$ i have already purchased taht card

OK Bro finally you won :),i can do it for you .

When will you need it.

Two of the three assignment are due this monday. The third one is due wed. If you fail to complete the one due on monday, i can still turn them late for less credit. Can you deal with these deadlines?

give me your email. i will send that i will send you a program that i have done in past so you know the stuff i have learned so far. I don't want you to use anything that we haven't learned or my teacher will get suspicious. And do you know understand this question?

one of the other questions is similiar to this one. You there? email?

Give me your i will send you mail.

economy1100@hotmail.com

check

sent you an email too.

i got your assignment.

*check_circle*

*check_circle*

*check_circle*

Secure Information

Content will be erased after question is completed.

*check_circle*