I need to get my code to output the same table as the example output.
The code first asks for a users inputs and then stores them in an array. Data is also validated upon entry. the months range from January to December and are meant to output all results in a table like the one in the desired output.
My code:
string[] salesReps = { "Dave", "Sarah", "Juan", "Gilno" };
string[] months = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep",
"Oct", "Nov", "Dec" };
int[,] salesStats = new int[4, 12];
//title
Console.Write("\n\nSales Figures\n");
Console.Write("*******************\n");
//sales
for (int i = 0; i < 4; i++)
{
Console.Write("\n");
Console.WriteLine("Enter the sales data for {0}", salesReps[i]);
for (int j = 0; j < 12; j++)
{
Console.Write(months[j] + ": ");
//validates entry
while (!int.TryParse(Console.ReadLine(), out salesStats[i, j]))
{
Console.Beep();
Console.WriteLine("Please enter only valid numbers!");
Console.Write(months[j] + ": ");
}
}
}
With the code I already have how would I achieve the desired output?
Desired output:

int[,] salesStats = new int[4, 12];, then you will need another (nested) loop to print the results. You will also need to store the names.