Hello
Help is appreciated in the following code. I am trying to multiply the first array ,collected from random numbers, by two.
When i run the code below:I get only the last number of the first array multiplied by two
using System;
public class Matrix
{
Random randomNumbers = new Random(); // random number generator
int matrix = 0;
int matrixTimesTwo;
int[] Array;
public void loadArray()
{
Array = new int[60];
Console.WriteLine("Load the Matrix");
for (int counter = 1; counter <= Array.Length; counter++)
{
matrix = randomNumbers.Next(1, 100);
Console.Write("{0} ", matrix); // display generated value
if (counter % 10 == 0)
Console.WriteLine();
}
}
public void doubleArray()
{
Array = new int[60];
Console.WriteLine("Load the MatrixTimes Two");
for (int counter = 1; counter <= Array.Length; counter++)
{
matrixTimesTwo = matrix * 2;
Console.Write("{0} ", matrixTimesTwo); // display generated value
if (counter % 10 == 0)
Console.WriteLine();
}
}
}
public class TheMatrix
{
public static void Main(string[] args)
{
Matrix myMatrix = new Matrix();
myMatrix.loadArray();
myMatrix.doubleArray();
}
}