Question: Ch 13ABSTRACT CLASSES AND INTERFACES Chapter 13 introduces us to super classes that force us to implement a specialized common behavior.In this chapter we learn
- Ch 13ABSTRACT CLASSES AND INTERFACES
Chapter 13 introduces us to super classes that force us to implement a specialized common behavior.In this chapter we learn that certain super classes are so abstract that it cannot be used to create any specific instances (i.e. using thenewoperator).These are Abstract classes.What's important is that these type of classes contain abstract methods(methods that specify how to call them, but do not contain implementation details).When an Abstract class is implemented by a subclass, the subclassmustspecify the code to implement those methods. This may sound confusing, but it gets clearer as you read the chapter and work through the exercises.
PROGRAM REQUIREMENTS:
Include a block comment header at the top of all programs with this information (or expect a penalty):
/**Programmer:{name}Date:{date}
Assignment:PEx.xxAssignment Name
Description:This program wlll... summarize
*/
- PROGRAMMING ASSIGNMENT:PE 13.17Complex classDue Date:MONDAYJuly 20, 2020*
VIDEO:https://us-lti.bbcollab.com/recording/18522ade659f42d7a57d76dd7320bcd6
A complex number is a number in the form a+bi, where a and b are real numbers and i is1.
The numbers a and b are known as the real part and imaginary part of the complex number, respectively.
You can performaddition,subtraction,multiplication,division, andabsolute valuefor complex numbers using the following formulas:
(A complex number can be interpreted as a point on a plane by identifying the (a,b) values as the coordinates of the point. The absolute value of the complex number corresponds to the distance of the point to the origin, as shown in Figure 13.10 .)
To receive full credit, complete the following requirements:
- Design a class namedComplexfor representing complex numbers
- Create methods:add,subtract,multiply,divide,andabsfor performing complex-number operations
- Override thetoStringmethod for returning a string representation for a complex number. The toString method returns (a+bi) as a string. Ifbis 0, it simply returnsa.
- Your Complex class should also implementCloneableandComparable. Compare two complex numbers using their absolute values.
- Provide three constructorsComplex(a, b),Complex(a), andComplex().Complex()creates a Complex object for number 0, andComplex(a)creates a Complex object with 0 for b. Also provide thegetRealPart()andgetImaginaryPart()methods for returning the real part and the imaginary part of the complex number, respectively.
- Draw theUML class diagramand implement the class.
- Write a test programthat prompts the user to enter two complex numbers and displays the result of their addition, subtraction, multiplication, division, and absolute value.Here is a sample run:
Enter the first complex number:3.55.5[Enter]
Enter the second complex number:-3.51[Enter]
(3.5 + 5.5i) + (-3.5 + 1.0i)=0.0 + 6.5i
(3.5 + 5.5i) - (-3.5 + 1.0i)=7.0 + 4.5i
(3.5 + 5.5i) * (-3.5 + 1.0i)=-17.75 + -15.75i
(3.5 + 5.5i) / (-3.5 + 1.0i)= -0.5094 + -1.7i
|(3.5 + 5.5i)|=6.519202405202649
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
