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,810 --> 00:00:11,200 Task. 4 00:00:11,200 --> 00:00:17,470 One is to ask the user three questions and notice that the user must submit their answer beside each 5 00:00:17,470 --> 00:00:18,130 question. 6 00:00:18,130 --> 00:00:19,990 So we will do just that. 7 00:00:20,200 --> 00:00:28,120 Over here we can say system, dot, dot, print, not print line, because we don't want to move to 8 00:00:28,120 --> 00:00:29,020 a new line. 9 00:00:29,740 --> 00:00:31,720 Pick a number to count by. 10 00:00:39,480 --> 00:00:43,050 Then we can say int step is equal to skin. 11 00:00:43,470 --> 00:00:44,490 Next int. 12 00:00:47,380 --> 00:00:47,800 All right. 13 00:00:47,800 --> 00:00:53,770 Next one is pick a number to start counting from system, dot, dot, print. 14 00:01:03,530 --> 00:01:07,280 End start is going to be equal to scandal next ent. 15 00:01:08,770 --> 00:01:11,620 And then pick a number to count to. 16 00:01:11,650 --> 00:01:16,960 So as you can see, the user is basically determining what the parameters of our loop will be. 17 00:01:19,250 --> 00:01:22,670 In this case, this one, it's going to end up determining the condition. 18 00:01:22,670 --> 00:01:27,350 So end stop is equal to skin dot next int. 19 00:01:28,710 --> 00:01:32,690 And now we can use this information to create a for loop. 20 00:01:32,700 --> 00:01:39,870 So for and I is equal to whatever the start value is, whichever number they want to start counting 21 00:01:39,870 --> 00:01:45,840 from, the loop is going to keep running so long as I is smaller than or equal to the stop. 22 00:01:47,080 --> 00:01:53,440 I hope you put smaller than or equal to not smaller then, because let's say they want to count up until 23 00:01:53,440 --> 00:01:54,070 ten. 24 00:01:54,100 --> 00:02:01,300 If you put smaller, then when I eventually does reach ten it's going to be smaller than the stop and 25 00:02:01,300 --> 00:02:02,960 the four loop is not going to run. 26 00:02:02,980 --> 00:02:06,370 Therefore, it won't print the number that you want to count to. 27 00:02:06,910 --> 00:02:09,280 So make sure you put smaller than or equal to. 28 00:02:09,310 --> 00:02:10,000 We'll break. 29 00:02:10,000 --> 00:02:11,830 Point it in just a second. 30 00:02:11,830 --> 00:02:18,880 And then every time the loop runs, we need to increase I by the number they want to count by the step. 31 00:02:18,880 --> 00:02:21,730 So I plus equal step. 32 00:02:24,030 --> 00:02:27,720 If they wanted to just count by one, then we would put in a plus plus. 33 00:02:27,720 --> 00:02:31,830 But the number we count by is determined by user input. 34 00:02:33,820 --> 00:02:40,480 And now we can just say system, dot, dot, print, not print line, because if you look back at the 35 00:02:40,480 --> 00:02:41,350 output. 36 00:02:42,400 --> 00:02:45,130 We need to print our account in a single line. 37 00:02:50,950 --> 00:02:51,790 And that is all. 38 00:02:52,180 --> 00:02:55,780 Now we can just visualize the runtime starting from here. 39 00:03:00,400 --> 00:03:03,430 The number I will count by is, let's say, two. 40 00:03:04,220 --> 00:03:08,120 The number I will start counting from, let's say, is six. 41 00:03:09,140 --> 00:03:12,020 And the number I want to count to is. 42 00:03:12,970 --> 00:03:14,590 How about 16? 43 00:03:15,860 --> 00:03:18,770 So I is going to start by equaling six. 44 00:03:18,800 --> 00:03:23,690 Six is smaller than or equal to 16, which means this four loop is going to run. 45 00:03:25,150 --> 00:03:27,610 And it's going to start by printing the number six. 46 00:03:28,000 --> 00:03:28,690 Beautiful. 47 00:03:28,690 --> 00:03:35,360 And once we get to here, I plus equal step is going to update the value on the left eye by two. 48 00:03:35,380 --> 00:03:37,600 So now I is going to equal eight. 49 00:03:39,080 --> 00:03:39,740 Ten. 50 00:03:40,540 --> 00:03:41,620 12. 51 00:03:42,240 --> 00:03:43,200 14. 52 00:03:44,390 --> 00:03:50,180 Once we get to here, 14 plus equal two is 16, which means this is going to run. 53 00:03:51,330 --> 00:03:55,110 Printing six up until 16 and check it out. 54 00:03:55,110 --> 00:03:58,380 We were able to start counting from six. 55 00:03:58,380 --> 00:04:02,670 We counted up until 16 and steps of two. 56 00:04:02,670 --> 00:04:06,900 And once you go back, 16 plus equal to is going to be 18. 57 00:04:06,900 --> 00:04:14,100 18 is not smaller than or equal to 16, which means this loop is going to break and your runtime will 58 00:04:14,100 --> 00:04:14,730 end.