Introduction to Java Programming and Data Structures, Comprehensive Version Plus MyProgrammingLab with Pearson EText -- Access Card Package
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
(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 test scores:");         print(scores);          System.out.println();…
(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();…
(Tic-Tac-Toe) Write a program that allows two players to play the tictac-toe game. Your program must contain the class ticTacToe to implement a ticTacToe object. Include a 3-by-3 two-dimensional array, as a private member variable, to create the board. If needed, include additional member variables. Some of the operations on a ticTacToe object are printing the current board, getting a move, checking if a move is valid, and determining the winner after each move. Add additional operations as needed.
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