Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi Help Me With The Following Program ! Program Statement A complex (“imaginary”

ID: 3614475 • Letter: H

Question

Hi Help Me With The Following Program !



Program Statement

A complex (“imaginary”) number has the form a +bi, where i is the square root of –1. Here, a is called the real part and b is calledthe imaginary part. Alternatively, a + bi can beexpressed as the ordered pair of real numbers (a, b).

Arithmetic operations on two complex numbers (a, b) and (c, d)are as follows:

(a, b) + (c, d) = (a + c, b + d)

(a, b) – (c, d) = (a – c, b – d)

(a, b) * (c, d) = ((a * c – b * d), (a * d + b * c))

(a, b) / (c, d) = (((a * c + b * d) / (c2 +d2 )) , ((b * c – a * d) / (c2 +d2 )))

Create a Complex number class that has two doublefields, one that represents the real part and one that representsthe imaginary part of a complex number. All class methodsshould use the this reference when referring to thecalling object. You should also have the following classmethods:

§ Three class constructors: a default constructor with the realpart assigned 1 and the imaginary part assigned 0 and anotherconstructor that has two parameters that initialize the real partand the imaginary part of the complex number and a copyconstructor..

§ One set operation with two parameters that assigns values of thereal part and the imaginary part of the complex number.

§ Two get operations: one that returns the real part and onethat returns the imaginary part.

§ Four arithmetic operations that will add, subtract, multiply, anddivide two complex numbers. These should be non-void(value-returning) methods that receive one Complex objectreturn one Complex object. (Do not use a shallowcopy).

§ AtoString method that writes only the value of theComplex object in the form a + bi .

§ An equals method that will compare two Complexobjects.

§ The class should use the this reference when referring tothe calling object.

The application program should contain at least two methods:

§ Anon-void (value-returning) method that determines if the values arevalid and returns a true or false. (See program specifics onnext page.)

§ Avoid method that prints, but does not call the arithmetic methods,the labelled results of all arithmetic operations. (Specifics for output on next page.)

Program Specifics:

1.                 Write the class and the application program

2.                 Include appropriate documentation for each file:

§ Declare one variable per line and include a comment after eachvariable declaration telling what the variable does

§ Each class method should have appropriate documentation. Thisdocumentation should include preconditions (what must be true whenthe method is called) and postconditions (what is true after themethod executes) for each method. The preconditions andpostconditions should appear between the method heading and themethod body.

§ Visually separate each method so that your source code is easy toread.

§ Use indentation so that all source code is easy to read.

3.                 Follow the naming conventions discussed in class for naming aclass, a variable and a method.

4.                 If the file is empty, then a message should be displayed and allprocessing terminated.

5.                 No calculations should be performed if the second set of values iszero for both the real and imaginary parts. An error messageshould be displayed and processing should continue with the nextset of numbers.

6.                 The application program should contain a while loop that endsprocessing when all of the data from one file has been read.

7.                 Each complex number should be displayed with at least one place tothe left of the decimal and two places to the right of thedecimal.

8.                 Your output should look similar to the output below:

SampleOutput

               The two numbers are:

               1.00 + 2.00i

               3.00 + 4.00i

               Sum is: 4.00 + 6.00i

               Difference is: -2.00 + -2.00i

               Product is: -5.00 + 10.00i

               Quotient is: 0.44 + 0.08i

Explanation / Answer

x.