Language: C# Please be as explicit as possible into the algorithm of the program
ID: 3886844 • Letter: L
Question
Language: C#
Please be as explicit as possible into the algorithm of the program!
Thanks!!!
a. Create a jagged array of type double. b. The array should be large enough to hold 50 rows (accounts). c. Ask the user which account (row) to work with: (1 - 50) d. In the console, ask the user how many columns a specific account holds: allocate that row's array to hold the number of elements the user specified. e. Just as in #5, allow the user to provide the input for each column in the selected row. f. When the user is finished (enters 0 for the account/row selection), write out the entire spreadsheet to a file called, "dynamicspreadsheet.dat"Explanation / Answer
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
double[][] jaggedArray = new double[50][];
int row, columns, i=0;
do
{
Console.WriteLine("Which row to work with");
row = Console.Read();
if (row == 0)
break;
Console.WriteLine("Enter columns for row");
columns = Console.Read();
jaggedArray[row - 1] = new double[columns];
while (i < columns)
{
Console.WriteLine("Provide input");
jaggedArray[row - 1][i] = Console.Read();
i++;
}
i = 0;
} while (row != 0);
for ( i = 0; i < 50; i++)
{
System.Console.Write("Element({0}): ", i);
for (int j = 0; j < jaggedArray[i].Length; j++)
{
System.Console.Write(jaggedArray[i][j]);
}
System.Console.WriteLine();
}
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.