1 00:00:00,210 --> 00:00:02,880 In this video, I'm going to go through tasks one to four. 2 00:00:06,390 --> 00:00:11,880 The first task is to ask the user how many historical figures they'd like to register, so pick up the 3 00:00:11,880 --> 00:00:13,800 number with scanned next and. 4 00:00:17,580 --> 00:00:22,500 And that's pretty much it, the second task is to make a tutelary name database. 5 00:00:24,750 --> 00:00:25,440 String. 6 00:00:26,610 --> 00:00:27,450 Database. 7 00:00:29,380 --> 00:00:31,420 Is equal to some number of rose. 8 00:00:34,610 --> 00:00:38,090 And some number of columns, some number of elements, Perreault. 9 00:00:39,070 --> 00:00:43,390 And now, since the data takes the form of a table in the array needs to have as many rows as there 10 00:00:43,420 --> 00:00:48,640 are historical figures, it makes sense that however many figures the user decides to input, that's 11 00:00:48,640 --> 00:00:50,650 going to determine the number of rows. 12 00:00:51,400 --> 00:00:56,290 And if you look at the example output, we know that each row was going to have three elements of data. 13 00:01:01,890 --> 00:01:04,840 Tasks threes to populate the 2D array with information. 14 00:01:05,310 --> 00:01:09,060 So first I'm going to make a for loop that runs through every row in the database. 15 00:01:23,040 --> 00:01:29,010 Each row contains three values, so during each one ask the user for three things their name, birthday 16 00:01:29,010 --> 00:01:33,200 and occupation, basically just copy the print statements that I left for you. 17 00:01:39,710 --> 00:01:41,990 And pick up each answer using next line. 18 00:01:51,470 --> 00:01:52,630 Run the code so far. 19 00:02:06,210 --> 00:02:11,009 And notice the bug, it's the classic scandal next line, Tropp. 20 00:02:17,740 --> 00:02:23,080 Remember, that scandal next line gets wasted when it's ahead of a next into next long next doubler 21 00:02:23,080 --> 00:02:23,590 next. 22 00:02:27,140 --> 00:02:31,310 And the solution is to add a throwaway next line just before the real next line. 23 00:02:32,530 --> 00:02:33,370 Run the code. 24 00:02:39,330 --> 00:02:40,980 Everything should work properly now. 25 00:02:41,990 --> 00:02:44,960 Here we enter the loop and it's asking me to enter information. 26 00:02:45,500 --> 00:02:49,280 I'm just going to stop the output with control, see, and we'll come back to this. 27 00:02:50,490 --> 00:02:56,040 All right, to the user is going to submit three values, Perreault As the user submits each value we 28 00:02:56,040 --> 00:02:56,850 need to store them. 29 00:02:57,480 --> 00:03:00,540 We're going to store the first value at index zero of Rahbi. 30 00:03:07,680 --> 00:03:10,950 We can store the second value in index one of rowby. 31 00:03:14,560 --> 00:03:18,070 And we can store the 3rd value in index two of RaouI. 32 00:03:19,570 --> 00:03:24,940 Already, each passing the for loop goes through a row and for each row we're updating the elements 33 00:03:24,940 --> 00:03:28,240 and indexes zero, one and two, let's run the code. 34 00:03:35,120 --> 00:03:37,400 I'm going to input two historical figures. 35 00:03:39,070 --> 00:03:41,410 They should create an array with two rows. 36 00:03:43,150 --> 00:03:48,370 Our tutera is going to have a length of two, which means the for loop is going to run twice and during 37 00:03:48,370 --> 00:03:51,730 each run we're populating one row in our two tutera. 38 00:03:55,720 --> 00:03:58,330 A populate the first row with the name of Marco Polo. 39 00:04:02,320 --> 00:04:03,300 I did a birth. 40 00:04:08,420 --> 00:04:10,250 And Marco Polo was a merchant. 41 00:04:14,020 --> 00:04:18,820 And notice that little space that we have between the submission and the next entry, that's because 42 00:04:18,820 --> 00:04:21,730 we have a new line being printed after it goes through a row. 43 00:04:22,510 --> 00:04:24,780 And now I can enter the information for the second row. 44 00:04:25,180 --> 00:04:26,530 I'm going to say Shakespeare. 45 00:04:30,690 --> 00:04:34,260 Date of birth, 26, 03, 15, 64. 46 00:04:38,220 --> 00:04:40,050 And Shakespeare was a playwright. 47 00:04:45,480 --> 00:04:50,160 OK, perfect, before we wrap up this task, we can have a little bit more fun in our loop. 48 00:04:52,910 --> 00:04:57,380 Right before we enter the information for each historical figure, I'm going to print the figure number. 49 00:05:01,300 --> 00:05:08,050 So here, I'll add another new line and a tab for aesthetic purposes, then we'll say figure Colen. 50 00:05:08,500 --> 00:05:11,680 And instead of printing, I, I'm going to print I plus one. 51 00:05:13,480 --> 00:05:18,040 Because I starts at zero and I don't want the order of each figure to start counting from zero, that'd 52 00:05:18,040 --> 00:05:18,820 be kind of weird. 53 00:05:19,390 --> 00:05:24,400 And also remember to put your arithmetic operations inside brackets when displaying them as part of 54 00:05:24,400 --> 00:05:24,900 a string. 55 00:05:25,300 --> 00:05:27,390 We talked about this all the way back in variables. 56 00:05:27,400 --> 00:05:29,260 But anyways, let's run the code. 57 00:05:32,090 --> 00:05:36,800 And everything looks pitch perfect, and when enter, the values are figure one. 58 00:05:46,890 --> 00:05:47,910 And figurative. 59 00:05:59,830 --> 00:06:02,950 So at this point, all of the information is inside the tutera. 60 00:06:04,540 --> 00:06:07,750 The next step is to make a function that prints the contents of the array. 61 00:06:11,190 --> 00:06:13,200 As always, it's going to be public static. 62 00:06:21,900 --> 00:06:26,850 The function is void and takes one parameter, a string to Deira called array. 63 00:06:32,780 --> 00:06:38,510 Now, the first instruction is to print the entire database and running through every value in a tiara 64 00:06:38,510 --> 00:06:39,900 requires a nested loop. 65 00:06:40,310 --> 00:06:43,310 So we're going to make an outer loop that runs through each arrow. 66 00:07:00,540 --> 00:07:04,050 And an inner loop that runs through every string in that row. 67 00:07:14,240 --> 00:07:17,570 And inside the inner loop, we're going to print an element in the array. 68 00:07:25,840 --> 00:07:27,220 With their own Ze'evi. 69 00:07:29,920 --> 00:07:33,040 And Jay is going to index every element in the current row I. 70 00:07:34,900 --> 00:07:38,440 Before we finish coding the logic inside printed today, right, I'm going to call it. 71 00:07:41,770 --> 00:07:46,930 Passing in our database is an argument because it's a good idea to keep testing the function as we update 72 00:07:46,930 --> 00:07:47,050 it. 73 00:07:58,060 --> 00:08:00,120 I'm going to put the same information as before. 74 00:08:17,190 --> 00:08:19,740 And it looks like it prints every string on the same line. 75 00:08:22,630 --> 00:08:25,330 So after each year, we need to add one line of space. 76 00:08:39,280 --> 00:08:41,770 I'll run the code and fast forward this time around. 77 00:08:47,020 --> 00:08:47,470 OK. 78 00:08:49,330 --> 00:08:54,010 And now if you look back at the image from the instruction, it tells us that each row precedes a tub 79 00:08:54,010 --> 00:08:58,090 of space and each string has one space from the other string. 80 00:08:58,780 --> 00:09:02,560 So we're going to add a tub of space before printing each Urhobo of values. 81 00:09:16,780 --> 00:09:19,390 And then I'm out of space after printing each value. 82 00:09:22,820 --> 00:09:24,080 I'm going to rerun the code. 83 00:09:32,800 --> 00:09:34,620 But the same information is before. 84 00:09:35,380 --> 00:09:37,480 First, I'll fill the info for Marco Polo. 85 00:09:43,130 --> 00:09:44,060 And Shakespeare. 86 00:09:54,420 --> 00:09:56,190 And this looks perfect. 87 00:09:56,220 --> 00:10:01,350 That is all for task for in part two of the solution, we're going to implement task number five.