*13.17(数学:Complex类)设计一个名为Complex的类来表示复数以及完成复数运算的add、substract、,ultiply、divide和abs方法,并且重写toString方法以返回一个表示复数的字符串。方法toString返回字符串a+bi。如果b是0,那么他返回a。Complex类还需要实现Cloneable和Comparable。使用他们的绝对值来比较两个复数。 提供三个构造方法Complex(a,b)、Complex(a)和Complex()。COmplex()为数字0创建Complex对象,而Complex(a)创建一个b为0的Complex对象。还提供getRealPart()和getImageinaryPart()方法以分别返回复数的实部和虚部。 绘制UML类图并实现该类。编写一个测试程序,提示用户输入两个复数,然后显示他们做加、减、乘、除之后的结果。下面是一个运行示例: Enter the first complex number: 3.5 5.5 Enter the second complex number: -3.5 1 (3.5 + 5.5 i ) + (-3.5 + 1.0 i ) = 0.0 + 6.5 i (3.5 + 5.5 i ) - (-3.5 + 1.0 i ) = 7.0 + 4.5 i (3.5 + 5.5 i ) * (-3.5 + 1.0 i ) = -17.75 + -15.75 i (3.5 + 5.5 i ) / (-3.5 + 1.0 i ) = -0.5094339622641509 + -1.7169811320754718 i *13.17(Math:Complex class)A class named complex is designed to represent complex number and add, substract, multiply, divide and ABS methods to complete complex operation, and override toString method to return a string representing complex number. Method toString returns the string a + bi. If B is 0, then he returns a. The complex class also needs to implement clonable and comparable. Use their absolute values to compare two complex numbers. Three construction methods, complex (a, b), complex (a) and complex(), are provided. Complex() creates a complex object for the number 0, while complex (a) creates a complex object with B = 0. Getrealpart() and getimagenarypart() methods are also provided to return the real and imaginary parts of a complex number, respectively. Draw UML class diagram and implement the class. Write a test program, prompt the user to enter two complex numbers, and then display their results after adding, subtracting, multiplying and dividing. Here is a running example: Enter the first complex number: 3.5 5.5 Enter the second complex number: -3.5 1 (3.5 + 5.5 i ) + (-3.5 + 1.0 i ) = 0.0 + 6.5 i (3.5 + 5.5 i ) - (-3.5 + 1.0 i ) = 7.0 + 4.5 i (3.5 + 5.5 i ) * (-3.5 + 1.0 i ) = -17.75 + -15.75 i (3.5 + 5.5 i ) / (-3.5 + 1.0 i ) = -0.5094339622641509 + -1.7169811320754718 i
Enter the first complex number:3.55.5
Enter the second complex number:-3.51(3.5+5.5 i )+(-3.5+1.0 i )=0.0+6.5 i
(3.5+5.5 i )-(-3.5+1.0 i )=7.0+4.5 i
(3.5+5.5 i )*(-3.5+1.0 i )=-17.75+-15.75 i
(3.5+5.5 i )/(-3.5+1.0 i )=-0.5094339622641509+-1.7169811320754718 i
Process finished with exit code 0