Now that we've seen the basics of working with these files, let's go ahead and solve a real problem, calculating the total number of babies born, total number of boys and total number of girls. In this case, I've created a new method totalBirths. To for us to work in. In this case I'm taking a file resource instead of having us choose. That'll make it easier for us to test and work with later. But I'm still going to use the same basic idea that I used in the previous one of looping over. And the previous problem of looping over all of the CSV records in the file. And I'm still gonna pass false, because it has no header row. So now, what we're going to do is, we're going to check out the number that were born each time. But we wanna add that to a running total of how many were born. So we're gonna create a variable called totalBirths, and we're gonna add to that the number born at this iteration of the loop. Problem with writing this piece of code here is that we can't both declare a variable and add onto it for this iteration of the loop in the same line. So we have to declare the variable someplace else. And the right place to do that is at the top of the method, before the loop is even started, with an initial value of 0, meaning we haven't seen any births. And then at each iteration through the loop, we calculate the total number that was born or add to the total births, the number that were born for that particular name. And then at the end we're going to print out the total number of births to see and verify whether or not we got the right thing. So let's just, again, run our simple little function just to see if we're, if it's gonna work. Now in this particular case since we've been passed a file resource. We even have a test method that allows us to choose which resource we're going to be using. We're not gonna have a dialogue box pop up this time because we already know what we want to work with. We've got that nice small example file that we're going to work with. So I've already put that information in there and I've already called total births to make sure that we're gonna be able to see our output. Since our code compiled, I'm gonna go ahead and create a new instance, and call Test total births, and I get that the total births were 1700. And again, if I look back at our example file, I'm adding 500 plus 400 plus 300 plus 200 plus 100 Plus 100, 40, 30, 20 and 10. I've added all these numbers up. I don't trust myself to do math on the fly, so in this spreadsheet, I've created a formula that will do the calculation for me and it came up with the number 1700 as well. So I feel pretty confident that this basic piece of code is doing what I want. Let's revisit this code and look at the total for total number of boys born and total number of girls born. In order to do that, we're gonna have to divide up the children based on their gender. So the way that I'm going to do that is, I'm going to check and see if the gender is a certain one. So, I'm gonna say if the current one dot get of one cuz again the second field is what represents a gender and if that equals male, say for example. Then, I want to add to a total for the total boys. So, equals [SOUND] the number born. And otherwise, I want to add one to the total girls instead. Obviously I need to create those variables. And again, on the assumption that only whole numbers of babies were born each time. I'm going to go ahead and make those ints and I'm gonna initialize all of the variables up here. And then again I'm going to add a print statement down here. To make sure that you're checking our information. Gonna compile quickly to check that I didn't make any silly mistakes and try testing this again. And now I get 1700, 1500, and 200. 1700, 1500, and 200. So, I think again that I feel somewhat confident that it seems to be working. But, just to make sure, I'm gonna try it on a larger data file. So, instead of example-small, I'm gonna try it on the year 2014 and try running that one. And in that case I get 3670151, 1768775, 1901376. I've done the same trick in my spreadsheet over here with letting it do the sums, and I see that I get the same numbers for total births, girls births, and boys births as what I calculated in my program. So again, I feel relatively confident that my solution is correct. In this code, an interesting question is, does it matter how the boy's and girl's names are organized in the file? That's right it doesn't for this code. For this code, since we check the gender each time, I could have the boy's names first then the girl's or I can even have the names interleaved. But in your files, all the girls' names are gonna be first, and all the boys' names are gonna be second, and that's gonna determine how you figure out what their ranking is. Since we weren't worried about ranking for this particular program, we didn't have to worry about that distinction, but you will in your code. Good luck with the mini project.