Question: JAVA 1. [10 marks] The UML class diagram represents a class to represent Complex number. A complex number has two parts, Complex one is real

JAVAJAVA 1. [10 marks] The UML class diagram represents a class to

1. [10 marks] The UML class diagram represents a class to represent Complex number. A complex number has two parts, Complex one is real and another part is imaginary. The imaginary part is expressed with an i, for example, 5.5+ 7.2i is a complex number where a = 5.5 and b = 7.2. You have to define the b: double implementation of the class according to the UML diagram. Complex(reat:double, imag: double) Complex) The default constructor creates an Object of Complex class, Complext Complex): Complex 0.0 +0.0i. The third constructor initializes the object same as adot Complex): Complex given object, t. The add method takes a Complex number *multiplyit Complex): Complex toString(): String object, t as parameter and returns a new Complex number after addingt with the object. The multiply method also returns a new Complex number as per mathematical formula given below. The toString method displays a complex number in the form of a + bi. 1. Addition: Z=X+Y - Z.a=X.a+Y.a and Z.b=X.b + Y.b 2. Multiplication: Z=X.Y - Z.a = X.a*Y.a-X.b*Y.b and Z.b = X.b*Y.a + X.a*Y.b

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!