Write a complex number class in java

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

Place your order
(550 words)

Approximate price: $22

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more

Order your essay today and save 30% with the discount code HAPPY