Question
Java Create a new class called Matrix which: Has a private 2-dimensional array to store double values A constructor which takes in the number of
Java
Create a new class called Matrix which:
Has a private 2-dimensional array to store double values
A constructor which takes in the number of rows and columns the matrix should have, and creates a 2D array with the same number of rows & columns, and initializes all its values to 0
Create a get function, which takes in the row and column numbers, and returns the value stored at that position
Create a set function, which takes in the row and column numbers and a value, and sets the value at the specified position to the given value
Create a toString() method which returns a string representation of the matrix
- One row per line
- Tab separated (or similar) for each column within the row
-Try to make it look good for varying sizes, consider using String.format here
Create a main method, in another file, to test your Matrix class
- Create a new class called Matrix which: - Has a private 2-dimensional array to store double values - A constructor which takes in the number of rows and columns the matrix should have, and creates a 2D array with the same number of rows \& columns, and initializes all its values to 0 - Create a get function, which takes in the row and column numbers, and returns the value stored at that position - Create a set function, which takes in the row and column numbers and a value, and sets the value at the specified position to the given value - Create a toString () method which returns a string representation of the matrix - One row per line - Tab-separated (or similar) for each column within the row - Try to make it look good for varying sizes, consider using String. format here - Create a main method, in another file, to test your Matrix class
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started