Question: Homework # 5 1 . Write a Java program that implements and tests the following interface for complex numbers: Test your class with the
Homework #
Write a Java program that implements and tests the following interface for complex numbers:
Test your class with the following main program:
public static void mainString args
Complex x new Complex;
Complex y new Complex;
Complex sum xplusy;
Complex prod ytimesx;
Complex power xpow;
System.out.printlnx;
System.out.printlny;
System.out.printlnsum;
System.out.printlnprod;
System.out.printlnpower;
System.out.printlnxisReal;
System.out.printlnynorm;
end of test program
Turn in a listing of your program, and the results of the test run.
Note: the methods plus and times do not mutate the complex number, but rather produce a new complex number as the result.
Extra Credit: Add a method norm that returns the Euclidean norm of the complex number. Test it by printing the norm of y Hint: the squareroot function is Math.sqrtt
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
