# Square - //...

This preview shows pages 1–2. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: // **************************************************************** // Square.java // // Define a Square class with methods to create and read in // info for a square matrix and to compute the sum of a row, // a column, either diagonal, and whether it is magic. // // **************************************************************** import java.util.Scanner; public class Square { int square; //-------------------------------------- //create new square of given size //-------------------------------------- public Square(int size) { square = new int[size][size]; } //----------------------------------------------- //return the sum of the values in the given row //----------------------------------------------- public int sumRow(int row) { int sum = 0; for (int col = 0; col &lt; square.length; col++) sum += square[row][col]; return sum; } //------------------------------------------------- //return the sum of the values in the given column //-------------------------------------------------...
View Full Document

## This note was uploaded on 03/22/2010 for the course CS 202 taught by Professor Fong during the Spring '10 term at SIU Carbondale.

### Page1 / 3

Square - //...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online