Introduction to Java Programming and Data Structures: Brief Version (11th Global Edition)
Introduction to Java Programming and Data Structures: Brief Version (11th Global Edition)
11th Edition
ISBN: 9780134671710
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
(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…
Please use easy logic with proper indentations and comments for understanding!. Coding should be in C++. 3. Define a class which stores up to 10 integer values in an array.  The class should also define the following 4 public methods:       setNumber – accepts an integer value to store in the array.  The value is stored in the next available element of the array (first call to the method stores the value in element 0 with the second call storing the value in element 1.) The method returns true if there is room in the array and the integer was successfully stored.  Returns false otherwise.        clear – removes all values from the array so that the array can be reused.     displayNumbers – displays the values currently stored in the array.     getStats – determines the largest, smallest, and average of the values currently stored in the array.  These values are returned to the caller via reference parameters. All methods should produce correct results regardless of the order in which…
(Querying an Array of Invoice Objects) Use the class Invoice provided in the lab assignment to create an array of Invoice objects.Class Invoice includes four properties—a PartNumber (type int), a PartDescription (type string), a Quantity of the item being purchased (type int) and a Price (type decimal).Write a console application that performs the following queries on the array of Invoice objects and displays the results:a) Use LINQ to sort the Invoice objects by PartDescription.b) Use LINQ to sort the Invoice objects by Price.c) Use LINQ to select the PartDescription and Quantity and sort the results by Quantity.d) Use LINQ to select from each Invoice the PartDescription and the value of the Invoice(i.e., Quantity * Price). Name the calculated column InvoiceTotal. Order the results by Invoice value. [Hint: Use let to store the result of Quantity * Price in a new range variable total.]e) Using the results of the LINQ query in Part d, select the InvoiceTotals in the range$200 to…
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