1 00:00:00,180 --> 00:00:03,870 Before we start, did you try solving the workbook yourself? 2 00:00:03,900 --> 00:00:09,660 If not, please click the link in the resources folder and follow the instructions for this workbook. 3 00:00:10,380 --> 00:00:14,280 The workbook contains an array that stores for prices can confirm. 4 00:00:14,280 --> 00:00:15,070 All right. 5 00:00:15,090 --> 00:00:18,180 Create another array after tax with the same length. 6 00:00:18,180 --> 00:00:20,160 So here we can say double. 7 00:00:21,150 --> 00:00:26,940 After tax is equal to a new array that can store values of type double. 8 00:00:26,970 --> 00:00:28,960 The length of the array is four. 9 00:00:28,980 --> 00:00:33,180 As you can clearly see, but I encourage you to put price dot length instead. 10 00:00:33,360 --> 00:00:36,680 It's better practice and you might be thinking why? 11 00:00:36,690 --> 00:00:39,540 Well, when you do it that way, it's more loosely coupled, right? 12 00:00:39,540 --> 00:00:42,990 Because let's say I add two more elements. 13 00:00:43,620 --> 00:00:49,500 Price length will still reflect the length of the array, but if initially it was four, I would have 14 00:00:49,500 --> 00:00:50,520 to change it to six. 15 00:00:50,520 --> 00:00:53,960 So it's always good to make sure that your code is loosely coupled. 16 00:00:53,970 --> 00:00:56,730 For that reason, it's better to reference the length of the array. 17 00:00:56,760 --> 00:00:59,520 All right, enough about that task too. 18 00:00:59,550 --> 00:01:02,040 So tax apparently is 13%. 19 00:01:02,070 --> 00:01:08,880 Use a loop to update each element and after tax to equal the original price plus tax. 20 00:01:09,240 --> 00:01:10,980 All right, simple enough. 21 00:01:11,310 --> 00:01:19,050 So I'll create a for loop where I starts at zero, because after tax is always going to have the same 22 00:01:19,050 --> 00:01:20,370 length as price. 23 00:01:20,400 --> 00:01:23,580 We can use either of their lengths for our condition. 24 00:01:24,840 --> 00:01:25,660 I Plus. 25 00:01:26,400 --> 00:01:31,470 So this loop is going to keep running so long as AI is smaller than the length of our array. 26 00:01:31,470 --> 00:01:38,010 And for every element that we go through, we're going to set that element equal to its corresponding 27 00:01:38,010 --> 00:01:42,150 price element plus that same price. 28 00:01:44,810 --> 00:01:46,250 Times the tax. 29 00:01:50,630 --> 00:01:51,530 All right. 30 00:01:52,260 --> 00:01:55,260 And now use arrays to string to print the arrays. 31 00:01:55,260 --> 00:02:03,330 I'm really glad that's the case because I don't feel like making another for loop arrays to string. 32 00:02:03,630 --> 00:02:05,880 Here we print the original prices. 33 00:02:07,170 --> 00:02:09,750 And here we print the prices. 34 00:02:11,900 --> 00:02:12,980 After tax. 35 00:02:17,510 --> 00:02:18,170 Beautiful. 36 00:02:18,410 --> 00:02:19,970 Put a breakpoint right here. 37 00:02:24,440 --> 00:02:27,590 So here, price stores four elements. 38 00:02:28,010 --> 00:02:28,640 Oh, sorry. 39 00:02:28,640 --> 00:02:30,680 This wasn't, I guess six. 40 00:02:30,680 --> 00:02:32,480 I forgot to remove these too. 41 00:02:32,510 --> 00:02:33,890 Anyways, does it matter? 42 00:02:35,220 --> 00:02:38,790 And after tax was initialized to have the exact same length. 43 00:02:38,790 --> 00:02:41,100 So it also has six elements. 44 00:02:41,100 --> 00:02:44,700 By default, they're all zero, so we need to start updating them here. 45 00:02:44,940 --> 00:02:47,280 The for loop starts at I equals zero. 46 00:02:47,280 --> 00:02:51,810 When I equals zero, the original price is $1.99. 47 00:02:52,020 --> 00:02:59,370 So the after tax price at index zero is going to equal the original price plus the tax. 48 00:03:01,240 --> 00:03:01,900 Beautiful. 49 00:03:02,780 --> 00:03:04,260 Now I equals one. 50 00:03:04,280 --> 00:03:12,260 The original price at index one is 299 and we're setting the element at index one of after tax equal 51 00:03:12,260 --> 00:03:14,060 to 2.99 plus tax. 52 00:03:16,150 --> 00:03:17,020 Splendid. 53 00:03:17,050 --> 00:03:19,480 Now I equals to the original price. 54 00:03:19,480 --> 00:03:21,030 There is 3.99. 55 00:03:21,040 --> 00:03:27,790 We're setting the element that index to of after tax equal to 3.99 plus tax. 56 00:03:29,070 --> 00:03:33,270 We keep doing that until the loop eventually runs to completion. 57 00:03:35,910 --> 00:03:38,550 The original prices are the following. 58 00:03:39,310 --> 00:03:41,950 And the after tax prices are those. 59 00:03:43,000 --> 00:03:43,930 And we're done.