Question: using Java programing create the followig: Design a class Complex. The class contains: 1. Data fields real and imaginary, that represent real and imaginary part
Design a class Complex. The class contains: 1. Data fields real and imaginary, that represent real and imaginary part of a complex number respectively. 2. A no-arg constructor that creates a Complex object. 3. A constructor that creates a Complex object with the specified real and imaginary part. 4. Two getter and setter methods. 5. A method to add two Complex objects. 6. A method to multiply two Complex objects. 7. Override the toString() method to display the output as: 2+3i, where 2 is the real part and 3 is the imaginary part Test your class using the following code in the main() method in your App class. Complex cl = new Complex(2,3);//243i Complex c2 = new Complex(8,5)://8+5i Complex c3 = new Complex(); Complex c4 = new Complex(); c3-cl.add(c2); System.out.println(c3);//should print 10+8i c4-el.multiply(c2); System.out.println(c4): should print 1+34
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
