Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/** * Java allows two-dimensional arrays, that is, an array of arrays. * In mathematics, a two-dimensional array, each with the same dimension, is called

/** * Java allows two-dimensional arrays, that is, an array of arrays. * In mathematics, a two-dimensional array, each with the same dimension, is called a matrix. * * This assignment will have you do a number of specific operations on a matrix. * The number of rows is given by the ROWS constant. Similarly, the number * of columns is given by the COLS constant. Do NOT hard code 8 for these values! * * Wherever you see the comment: * // your code goes here * you have some coding to do to complete the method. * The documentation for the method appears above its declaration. * *

* * When submitting attach you Main.java to Canvas. The first line * See suggested order of implementation in main() method below. */

public class Main { public static int [] [] matrix; public static final int ROWS = 8; public static final int COLS = 8; /** * Allocate space for the matrix. */ public static void initialize() { // your code goes here. } /** * Fill the entire matrix with the given value. * @param value is the value to use to fill. */ public static void fillWithValue(int value) { // your code goes here. } /** * Fill the matrix with a checkerboard pattern of 1s and 0s * @param firstValue is either a 1 or a 0. It goes in matrix[0][0] * (upper left corner) of the matrix. The pattern alternates from there. */ public static void fillCheckerboard(int firstValue) { // your code goes here. } /** * Fill the outside rows and columns of matrix with zeros. * The interior values should *not* be altered. */ public static void fillBoardersWithZeros() { // your code goes here. } /** * Compute the sum of the values in the entire matrix. * @return sum of values. */ public static int sumOfValues() { int sum = 0; // your code goes here. return sum; } /** * Print the matrix (no extra spaces) to the console. */ public static void printMatrix() { // your code goes here. } public static void main(String[] args) { // Suggested order: // initialize() // fillWithValue() // printMatrix() // sumOfValues() // remaining methods. Also print a blank line after each call to printMatrix()

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database Administration The Essential Reference

Authors: Brian Laskey, David Kreines

1st Edition

1565925165, 978-1565925168

More Books

Students also viewed these Databases questions

Question

Describe how leadership styles should be adapted to the situation

Answered: 1 week ago