[Script Info] Title: [Events] Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text Dialogue: 0,0:00:00.40,0:00:02.76,Default,,0000,0000,0000,,I'm going to show you two ways to do this. Dialogue: 0,0:00:02.76,0:00:05.26,Default,,0000,0000,0000,,We know that for each student, we want to write Dialogue: 0,0:00:05.26,0:00:08.19,Default,,0000,0000,0000,,that student's total into an array and return it. We Dialogue: 0,0:00:08.19,0:00:10.28,Default,,0000,0000,0000,,also know exactly how big we want the array to Dialogue: 0,0:00:10.28,0:00:14.18,Default,,0000,0000,0000,,be because we want one for each student. So I Dialogue: 0,0:00:14.18,0:00:17.06,Default,,0000,0000,0000,,want numStudents items in my array. Now, for all of Dialogue: 0,0:00:17.06,0:00:21.07,Default,,0000,0000,0000,,the student from the 0 student to the last student Dialogue: 0,0:00:22.29,0:00:25.64,Default,,0000,0000,0000,,Going up one at a time. I want to fill that student's Dialogue: 0,0:00:25.64,0:00:28.51,Default,,0000,0000,0000,,spot in the array of totals with that Dialogue: 0,0:00:28.51,0:00:31.53,Default,,0000,0000,0000,,student's total. I already have a method that calculates Dialogue: 0,0:00:31.53,0:00:35.50,Default,,0000,0000,0000,,this. So, I can use totalForStudent. And then, Dialogue: 0,0:00:35.50,0:00:37.03,Default,,0000,0000,0000,,when I've done that for all of the students, Dialogue: 0,0:00:39.12,0:00:41.47,Default,,0000,0000,0000,,I can return the totals. Looks like I forgot to Dialogue: 0,0:00:41.47,0:00:45.49,Default,,0000,0000,0000,,call it totals. Let's check that it works. I'll run Dialogue: 0,0:00:45.49,0:00:48.13,Default,,0000,0000,0000,,the tester, and it looks like it's got what I Dialogue: 0,0:00:48.13,0:00:52.63,Default,,0000,0000,0000,,expecting. Now, we could use nested for loops. I'll still Dialogue: 0,0:00:52.63,0:00:54.15,Default,,0000,0000,0000,,want all of my totals, and I'll still want to Dialogue: 0,0:00:54.15,0:00:57.98,Default,,0000,0000,0000,,return them, but let's think about solving this problem for Dialogue: 0,0:00:57.98,0:01:01.50,Default,,0000,0000,0000,,just one student, for each topic, starting with the first Dialogue: 0,0:01:01.50,0:01:04.68,Default,,0000,0000,0000,,one. And we going up to the number of topics, Dialogue: 0,0:01:04.68,0:01:07.01,Default,,0000,0000,0000,,one at a time. I'll add the score Dialogue: 0,0:01:07.01,0:01:10.36,Default,,0000,0000,0000,,for that topic to that student's total, let's say Dialogue: 0,0:01:10.36,0:01:13.12,Default,,0000,0000,0000,,for now I'm thinking about student 1. To Dialogue: 0,0:01:13.12,0:01:16.67,Default,,0000,0000,0000,,calculate total for student 1, I'll start at 0 Dialogue: 0,0:01:16.67,0:01:19.60,Default,,0000,0000,0000,,and for each topic And want to add Dialogue: 0,0:01:19.60,0:01:23.35,Default,,0000,0000,0000,,that student's grade, in that topic. Then, once I Dialogue: 0,0:01:23.35,0:01:25.80,Default,,0000,0000,0000,,have the student total in my larger array Dialogue: 0,0:01:25.80,0:01:30.16,Default,,0000,0000,0000,,totals, I'll set the total for that student to Dialogue: 0,0:01:30.16,0:01:31.83,Default,,0000,0000,0000,,be the student total that I just calculated. Dialogue: 0,0:01:33.01,0:01:34.54,Default,,0000,0000,0000,,So this is what I do for one student. Dialogue: 0,0:01:34.54,0:01:36.30,Default,,0000,0000,0000,,And now, I want to do that for every single Dialogue: 0,0:01:36.30,0:01:39.23,Default,,0000,0000,0000,,student. So that all of the spaces in total Dialogue: 0,0:01:39.23,0:01:41.79,Default,,0000,0000,0000,,gets filled, so I will indent that a little Dialogue: 0,0:01:41.79,0:01:46.25,Default,,0000,0000,0000,,bit and now for each student starting with the Dialogue: 0,0:01:46.25,0:01:48.41,Default,,0000,0000,0000,,zeroth one so we don't need this line anymore Dialogue: 0,0:01:48.41,0:01:50.96,Default,,0000,0000,0000,,I will go up to the number of students Dialogue: 0,0:01:53.38,0:01:58.43,Default,,0000,0000,0000,,one at a time. I will do all of these steps. So Dialogue: 0,0:01:58.43,0:02:03.44,Default,,0000,0000,0000,,now the inter-loop is calculating the student totals and the outer loop is Dialogue: 0,0:02:03.44,0:02:08.70,Default,,0000,0000,0000,,storing the student totals in totals. So now we're fix up syntax errors. And Dialogue: 0,0:02:08.70,0:02:11.13,Default,,0000,0000,0000,,this way should work just like the last one. I'll Dialogue: 0,0:02:11.13,0:02:13.31,Default,,0000,0000,0000,,run it to make sure and it looks like it's Dialogue: 0,0:02:13.31,0:02:17.01,Default,,0000,0000,0000,,still good. Hopefully the number of values you see here. Dialogue: 0,0:02:17.01,0:02:18.48,Default,,0000,0000,0000,,Makes it obvious why it would be be nice as Dialogue: 0,0:02:18.48,0:02:20.00,Default,,0000,0000,0000,,a teacher, have a computer do this for you.