Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have this code so far for this homework. could anyone please help me to find out the grand total of 102 ? 1. Develop

I have this code so far for this homework. could anyone please help me to find out the grand total of 102 ? image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
1. Develop a class TwoWayTable to hold and print a table of integers. Your class should be capable of holding a rectangular table of any size (i.e., 3 rows and 5 columns, 8 rows and 4 columns, etc.). Store the table cells (the integers) in a two-dimensional array of integers. Make sure you copy the actual table values into the array in your class. Don't just copy the reference that comes in through the constructor. Also, store the row sums and column sums in two separate one-dimensional integer arrays of the appropriate size. Finally, hold the grand total, i.e., the sum of all the table entries in an integer variable. Provide a constructor that accepts a two-dimensional integer array as its argument, and a method that computes the row sums, column sums and grand total. Finally, write a toString() method that formats the table as nicely as possible. package com.company; Eclass TwoWay Table { int numrows; int numcols; int(0) cell; int[] rowSum; int[] colSum; int grandTotal; Il constructor public TwoWay Table (int[][] data) { // add code here cell = data;//assigning data to array 1/calculating no of rows and columns numRows = cell.length; numCols = cell[@].length; setMargins(); I 1/calculating method to calculate row sum column sum and tota void setMargins() { 11 compute the row and column sums; 1/creating matrices to hold column sum and row sum BE a 99 21 void setMargins() { all compute the row and column sums; //creating matrices to hold column sum and row sum Colsum = new int[numCols]; rowSum = new int[numRows); // "margins" is the statistician's term // for these totals, since they appear e . 2 3 el "in the margins" int rsum = m; int csum = 0; 1/calculating rowSum 1 5 6 for (int i = @; i

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

Step: 3

blur-text-image

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

Beginning VB.NET Databases

Authors: Thearon Willis

1st Edition

1594864217, 978-1594864216

More Books

Students also viewed these Databases questions