Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Currently, I have the program to iterate by 1 and the 2D matrix is set for [8, 7

ID: 3744173 • Letter: C

Question

Currently, I have the program to iterate by 1 and the 2D matrix is set for [8, 7]

I would like to iterate the method return by increments of 3, but I don't seem to be able to get the call to work.

The output I want is:

3 6 9 12 15 18 21

24 27 30 33 36 39 42

45 48 51 5457 60 63

66 69 72 75 78 81 84

97 90 9396 99 102 105

108 111 114 117 120 123 126

129 132 135 138 141 144 147

150 153 156 159 162 165 168

** I know if I change the line mat1[row, col] = currCounter++; to mat1[row, col] = 3 * currCounter++; it works, but I am creating multiple matrices that will be increamenting.

class Program

{

public static int matrixBuilder(int currCounter)

{

int[,] mat1 = new int[8, 7];

int rowCount = mat1.GetLength(0);

int colCount = mat1.GetLength(1);

for (int row = 0; row < rowCount; row++)

{

for (int col = 0; col < colCount; col++)

{

mat1[row, col] = currCounter++;

Console.Write("{0} ", mat1[row, col]);

}

Console.WriteLine(" ");

}

return currCounter++;

}

static void Main(string[] args)

{

matrixBuilder(3);

Console.ReadLine();

}

Explanation / Answer

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace MatrixBuilder { class Program { public static int matrixBuilder(int currCounter) { int[,] mat1 = new int[8, 7]; int rowCount = mat1.GetLength(0); int colCount = mat1.GetLength(1); int num = 3; for (int row = 0; row
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote