1 00:00:00,210 --> 00:00:03,810 Before we start, did you try solving the workbook yourself? 2 00:00:03,840 --> 00:00:09,600 If not, please click the link in the resources folder and follow the instructions for this workbook. 3 00:00:10,750 --> 00:00:12,280 Welcome to Work Book 5.2. 4 00:00:12,310 --> 00:00:15,700 It's telling me to see to learn the part for the instructions. 5 00:00:15,730 --> 00:00:17,050 Let's do just that. 6 00:00:17,080 --> 00:00:23,680 So task one is to ask Bart to enter a line that he wants us to write. 7 00:00:23,920 --> 00:00:28,780 So here we can just say string line. 8 00:00:29,140 --> 00:00:30,890 Got to define scanner first. 9 00:00:30,910 --> 00:00:40,600 Scanner scan is equal to a new scanner instance that can detect input from the system. 10 00:00:42,190 --> 00:00:46,240 Okay, so string line is equal to skin dot next line. 11 00:00:48,710 --> 00:00:49,070 All right? 12 00:00:49,070 --> 00:00:54,230 And whatever Bart asks us to print, we need to print it 99 times. 13 00:00:54,500 --> 00:00:59,000 And it also tells us to number each line starting from one. 14 00:00:59,500 --> 00:01:06,260 All right, So our start index needs to be one, and I is equal to one. 15 00:01:07,040 --> 00:01:10,010 We want the last number to be 99. 16 00:01:10,010 --> 00:01:10,430 Right. 17 00:01:10,430 --> 00:01:17,000 So you would want to say I is smaller than 100 or I is smaller than or equal to 99. 18 00:01:20,310 --> 00:01:26,790 It doesn't really matter which one you choose because both conditions will accept a value of 99 and 19 00:01:26,790 --> 00:01:30,030 both conditions will reject a value of 100. 20 00:01:31,560 --> 00:01:34,410 So you choose which one that you want to go for. 21 00:01:34,440 --> 00:01:37,260 I will go for this one, and then I will just print. 22 00:01:38,300 --> 00:01:38,930 I. 23 00:01:41,460 --> 00:01:43,620 Followed by a dot. 24 00:01:44,810 --> 00:01:48,950 And whatever Bart asks us to print. 25 00:01:50,230 --> 00:01:53,350 All right, Now I'm going to visualize the runtime. 26 00:01:57,880 --> 00:01:59,350 What do you want me to write? 27 00:01:59,380 --> 00:02:01,810 I'm guessing we'll just put. 28 00:02:03,440 --> 00:02:07,670 I will not forget semicolons. 29 00:02:10,770 --> 00:02:11,220 All right. 30 00:02:11,220 --> 00:02:13,770 So I start at one. 31 00:02:13,770 --> 00:02:16,260 One is smaller than or equal to 99. 32 00:02:16,260 --> 00:02:20,280 So this four loop is going to run printing the following message. 33 00:02:20,280 --> 00:02:24,990 We're off to a good start because our number starts from one as was instructed. 34 00:02:24,990 --> 00:02:27,240 And now obviously, I'm going to fast forward. 35 00:02:29,560 --> 00:02:33,340 All right, So now I'm at 96, 97. 36 00:02:34,460 --> 00:02:35,570 98. 37 00:02:36,360 --> 00:02:37,380 99. 38 00:02:37,830 --> 00:02:45,060 And now when it goes back, I A-plus plus is going to increase I to then equal 100 100 is not smaller 39 00:02:45,060 --> 00:02:48,750 than or equal to 99, which means our for loop is going to break. 40 00:02:49,260 --> 00:02:55,770 And that is all we've successfully emulated the exact same output inside of learn the part. 41 00:02:55,860 --> 00:03:03,030 It starts from one and it ends at 99 and total printing our message 99 times. 42 00:03:03,030 --> 00:03:06,540 And as always, do not forget to close scanner. 43 00:03:07,840 --> 00:03:08,260 All right. 44 00:03:08,260 --> 00:03:10,690 That is all for workbook 5.2.