Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 19, Problem 19.11PE
Program Plan Intro

ComplexMatrix

Program Plan:

  • Include a class name named “Exercise19_11”.
    • Declare util package.
    • Declare main method.
      • Define the matrices “arr1” and “arr2” using the class “Complex”.
      • Using “for” loop, generate values into arrays.
      • Add and multiply the matrices and multiply the matrices using “GenericMatrix” class.
    • Define the method named “removeDuplicates”.
      • Define the object “ans” for “ArrayList” class.
      • Using condition, check the duplicate values in arrays and return the result.
  • Include a class name named “ComplexMatrix” which extends the “GenericMatrix”.
    • Define the method named “add()” which add two matrices and return the resultant value.
    • Define the method named “multiply()” which multiplies two matrices and return the resultant value.
    • Define the method named “zero()” which fills “0” to matrices.
  • Include an abstract class name named “GenericMatrix”.
    • Declare the methods “add”, “multiply”, and “zero” with generic object “E”.
    • Define all the methods with their arguments.
    • Define “printResult()” method to print the resultant values on screen.
  • Include a class name named “Complex”.
    • Declare package.
    • Declare main method.
    • Declare double variables “a” and “b”.
    • Declare Constructors that creates a complex object for number 0.
    • Declare a constructor that creates a complex object with 0 for b.
    • Declare a constructor that creates a complex object with specified a and b.
    • Declare a method to return real part of complex number.
    • Declare a method to return imaginary part of complex number.
    • Declare a method to add a complex number to this complex number.
    • Create a method to subtract a complex number from this complex number.
    • Create a method to multiply a complex number by this complex number.
    • Create a method to divide a complex number by this complex number.
    • Create a method that returns the absolute value of this complex number.
    • The protected clone method defined in the Object class is overridden, its accessibility is strengthened.
    • Close the main method.

Blurred answer
Students have asked these similar questions
[In c#] Write a class with name Arrays . This class has an array which should be initialized by user.Write a method Sum that should sum even numbers in array and return sum. write a function with name numFind in this class with working logic as to find the mid number of an array. After finding this number calculate its factorial.Write function that should display sum and factorial.Don’t use divide operator
(Java) Open up Eclipse and create a new class called ArrayListPractice.java Next, copy and paste the below program into your file and run the code. Your job is to take the given code, remove all the arrays and replace them with the identical ArrayLists. There should be no arrays in your program. You will need to call the ArrayList methods as defined in the lesson notes above. Note that you will not be able to do method overloading with ArrayLists so you should assign different names to your methods. Once you have made the changes, you should get identical output as the given version of the program. Submit your program when you are finished. /** * @author * CIS 36B * Activity 5.2 */import java.util.ArrayList;import java.util.Scanner;public class ArrayListPractice {    public static void main(String[] args) {                int scores[] = {95, 96, 97, 98, 99};        System.out.println("Integer exam scores:");        print(scores);        System.out.println();…
(Geometry: MyRectangle2D class)  Define the  MyRectangle2D class that contains:  Two double data fields named x and y that specify the center of the rectangle with getter and setter methods. (Assume the rectangle sides are parallel to the x- or y-axis.) The data fields width and height with getter and setter methods. A no-arg constructor that creates a default rectangle with (0, 0) for (x, y) and 1 for both width and height. A Constructor that creates a rectangle with the specified x, y, width, and height. A method getArea() that returns the area of the rectangle. A method getPerimeter() that returns the perimeter of the rectangle. A method contains(double x, double y) that returns true if the specified point (x, y) is inside this rectangle (see Figure 10.24a ). A method contains(MyRectangle2D r) that returns true if the specified rectangle is inside this rectangle (see Figure 10.24b ). A method overlaps(MyRectangle2D r) that returns true if the specified rectangle overlaps with this…
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education