frankcollins3 / fcc-mcsft-cSharp

FreeCodeCamp & Microsoft C# course:
1 stars 0 forks source link

2d array in C#? nesting arrays into another array [10:46pm] #6

Closed frankcollins3 closed 1 year ago

frankcollins3 commented 1 year ago

attempting to do: initialize Length == 5 array that holds 5 test scores to gather averages.

wrote a cb() that takes (student: string) (grade: number) params to: print to Console a msg returning the letter grade (A+ .. D- .. F etc) to correspond to number of grade. Screen Shot 2023-09-06 at 10 46 28 PM

Screen Shot 2023-09-06 at 10 46 23 PM

aiming to make an array of all the students names and loop over the array and create random values

error: conceptualizing the plan of array use.

proposed approach: 2d matrix ?

0: can also hard code things but want to be more algorithmic.

frankcollins3 commented 1 year ago

first approach is minimum viability based: just loop over 1 student and get 5 random test scores.

// Now how to do a forloop instead of foreach to limit loop by 5

foreach should be automatically constrained in its loop count by array contents but double checking [10:51pm]

frankcollins3 commented 1 year ago

👍 int[] sophia = new int [5]; int[] andrew = new int [5]; int[] emma = new int [5]; int[] logan = new int [5];

// 2d matrix array 
int[][] studentArrays = new int[4][];
studentArrays[0] = sophia;
studentArrays[1] = andrew;
studentArrays[2] = emma;
studentArrays[3] = logan;

[11:39am]