1 00:00:00,090 --> 00:00:03,120 This video present the solution to workbook 3.7. 2 00:00:03,150 --> 00:00:05,790 Task number one is to pick up the user's decision. 3 00:00:05,790 --> 00:00:15,060 So here we can say string decision is equal to skin dot next line and if the decision equals yes. 4 00:00:15,060 --> 00:00:19,020 So if decision dot equals the string. 5 00:00:19,020 --> 00:00:19,920 Yes. 6 00:00:21,170 --> 00:00:27,320 Then we're going to dump all of this code inside of this if statement. 7 00:00:29,680 --> 00:00:35,320 If they are here to get a mortgage, then we will execute all of the code that is involved in granting 8 00:00:35,320 --> 00:00:36,340 them a mortgage. 9 00:00:36,520 --> 00:00:40,510 Otherwise, else we will print OC. 10 00:00:40,540 --> 00:00:42,130 Have a nice day. 11 00:00:44,540 --> 00:00:44,960 Okay. 12 00:00:45,170 --> 00:00:48,200 So that was task number two for you. 13 00:00:48,230 --> 00:00:50,660 Let's go ahead and visualize the runtime. 14 00:00:50,690 --> 00:00:54,380 I'm only going to put breakpoints here. 15 00:00:54,860 --> 00:00:59,930 We only need one breakpoint to remember to visualize F and L statements. 16 00:01:00,320 --> 00:01:02,090 And that should be good. 17 00:01:03,180 --> 00:01:04,560 We'll debug the runtime. 18 00:01:06,860 --> 00:01:12,160 So here it's asking me if I want to get a mortgage, if I execute this line of code scanned. 19 00:01:12,290 --> 00:01:15,830 Next line is going to wait for me to enter any string value. 20 00:01:17,030 --> 00:01:18,860 And that's exactly what it does. 21 00:01:18,890 --> 00:01:23,080 I'm going to enter a decision of either yes or no. 22 00:01:23,090 --> 00:01:26,030 In this case, Yes, if I want this to execute. 23 00:01:28,330 --> 00:01:29,230 All right. 24 00:01:29,590 --> 00:01:31,570 The decision variable equals. 25 00:01:31,570 --> 00:01:32,040 Yes. 26 00:01:32,050 --> 00:01:34,990 So this is going to evaluate to true. 27 00:01:35,020 --> 00:01:42,190 Remember, do not press continue, continue continues to the next breakpoint, since there are no other 28 00:01:42,190 --> 00:01:48,670 breakpoints, it's just going to resume execution of our code until the application completes normally. 29 00:01:48,670 --> 00:01:51,160 So we're going to step over this conditional. 30 00:01:52,200 --> 00:01:57,510 And we can visualize what happens inside of it line by line, by stepping over each line. 31 00:01:57,540 --> 00:02:01,230 Right now, it just prints a bunch of messages. 32 00:02:01,230 --> 00:02:05,820 So we need to write all of the relevant code in the event that the user wants to get a mortgage. 33 00:02:05,850 --> 00:02:07,980 Now let us restart the runtime. 34 00:02:10,280 --> 00:02:11,810 By pressing continue scan. 35 00:02:11,810 --> 00:02:14,150 The next line waits for me to enter any value. 36 00:02:14,180 --> 00:02:15,200 I'm going to enter. 37 00:02:15,200 --> 00:02:18,260 No, no does not equal yes. 38 00:02:18,260 --> 00:02:20,240 So this will evaluate the false. 39 00:02:21,140 --> 00:02:25,820 If I press step over, it goes to the LL statement and it prints. 40 00:02:25,850 --> 00:02:26,360 Okay. 41 00:02:26,390 --> 00:02:27,240 Have a nice day. 42 00:02:27,260 --> 00:02:30,740 Now I can press continue to resume program execution. 43 00:02:32,620 --> 00:02:32,990 Prince. 44 00:02:33,010 --> 00:02:33,360 Okay. 45 00:02:33,370 --> 00:02:34,300 Have a nice day. 46 00:02:34,570 --> 00:02:37,120 All right, Let us finish writing the code here. 47 00:02:37,540 --> 00:02:41,080 We will say double savings is equal to skin. 48 00:02:41,350 --> 00:02:45,220 Next double to pick up how much money they have in their savings account. 49 00:02:45,220 --> 00:02:48,310 And double debt is equal to skin. 50 00:02:48,580 --> 00:02:50,050 Next double once again. 51 00:02:50,290 --> 00:02:52,060 How many years have you worked for? 52 00:02:52,090 --> 00:02:54,060 That seems like a whole number to me. 53 00:02:54,070 --> 00:02:57,370 End years is equal to skin. 54 00:02:57,760 --> 00:02:58,930 Next int. 55 00:03:04,350 --> 00:03:05,450 What is your name? 56 00:03:05,460 --> 00:03:07,860 String name is equal to skin. 57 00:03:08,160 --> 00:03:09,090 Next line. 58 00:03:09,090 --> 00:03:15,090 But remember when next line comes after a next end, next double or a next, we need to put in a throwaway 59 00:03:15,090 --> 00:03:15,990 next line. 60 00:03:18,410 --> 00:03:23,470 Right before the quote unquote, real next line, the one that actually matters. 61 00:03:23,480 --> 00:03:25,040 So this one is going to get skipped. 62 00:03:25,040 --> 00:03:30,590 This one is going to get wasted while this one actually waits for the user to enter in a string, which 63 00:03:30,590 --> 00:03:33,260 will then get stored in a name variable. 64 00:03:33,590 --> 00:03:34,880 All right. 65 00:03:34,910 --> 00:03:40,190 Now, we want to approve the mortgage if they meet the requirements that were specified in the article. 66 00:03:40,310 --> 00:03:47,990 So you'll remember the requirements for them to be approved for a mortgage are if their savings are 67 00:03:47,990 --> 00:03:49,430 at least 10,000. 68 00:03:50,090 --> 00:03:54,090 So if their savings are greater than or equal to $10,000. 69 00:03:55,030 --> 00:04:00,210 And they need to also have less than $5,000 in debt. 70 00:04:00,220 --> 00:04:03,670 So the debt also has to be less than 5000. 71 00:04:03,700 --> 00:04:06,820 And they need more than two years of work experience. 72 00:04:06,820 --> 00:04:08,020 So end. 73 00:04:09,010 --> 00:04:11,650 Years has to be more than two. 74 00:04:12,680 --> 00:04:18,700 If the user meets all of these requirements, then we can approve them for a mortgage. 75 00:04:18,709 --> 00:04:23,600 We can say congratulations, whoever, whatever their name ends up being. 76 00:04:23,600 --> 00:04:28,100 Congratulations name you have been approved else. 77 00:04:30,050 --> 00:04:30,710 Sorry. 78 00:04:30,710 --> 00:04:33,620 You are not eligible for a mortgage. 79 00:04:35,440 --> 00:04:36,490 And that song. 80 00:04:37,000 --> 00:04:39,100 Let us visualize the runtime. 81 00:04:42,940 --> 00:04:46,360 By pressing continue, it's going to execute this line of code. 82 00:04:46,360 --> 00:04:49,720 And next line here waits for me to enter in a string. 83 00:04:49,840 --> 00:04:50,800 I'm going to enter. 84 00:04:50,800 --> 00:04:51,580 Yes. 85 00:04:51,730 --> 00:04:54,460 The decision yes equals the string. 86 00:04:54,460 --> 00:04:55,090 Yes. 87 00:04:55,090 --> 00:04:59,590 So this will evaluate to true executing the if statement. 88 00:05:00,190 --> 00:05:06,010 Remember not to press continue because continue continues to the next breakpoint, but there are no 89 00:05:06,010 --> 00:05:06,940 other breakpoints. 90 00:05:06,940 --> 00:05:11,710 So it's just going to resume execution of our program until it completes naturally. 91 00:05:11,710 --> 00:05:17,200 So we will step over this conditional and step over every single line inside of it. 92 00:05:17,320 --> 00:05:17,890 Great. 93 00:05:17,890 --> 00:05:20,410 In one line, how much money do you have in your savings? 94 00:05:20,410 --> 00:05:23,470 You will step over this line, Keep stepping over. 95 00:05:23,470 --> 00:05:28,030 Now I need to input my savings and debt in one line. 96 00:05:28,030 --> 00:05:31,300 So if I say 20,000. 97 00:05:33,110 --> 00:05:35,000 Followed by 2000. 98 00:05:38,180 --> 00:05:39,110 This scandal. 99 00:05:39,110 --> 00:05:42,950 Next double is going to scan for the first double value that we input. 100 00:05:42,950 --> 00:05:49,280 And this scandal next double will skin for the next double separated by white space. 101 00:05:49,370 --> 00:05:50,780 Let's test this out. 102 00:05:53,400 --> 00:05:54,300 And beautiful. 103 00:05:54,300 --> 00:06:00,210 Just as I predicted, this one picked up this value, and after stepping over this one, it scanned 104 00:06:00,210 --> 00:06:01,470 for the next double. 105 00:06:01,470 --> 00:06:03,750 That was the limited by a white space. 106 00:06:03,930 --> 00:06:07,580 So now this variable stores the value 20,000. 107 00:06:07,590 --> 00:06:10,140 That's variable stores of the value 2000. 108 00:06:10,170 --> 00:06:12,090 How many years have you worked for? 109 00:06:13,170 --> 00:06:18,750 We're going to put three years so that we're approved for the mortgage. 110 00:06:19,800 --> 00:06:21,220 What is your name? 111 00:06:21,240 --> 00:06:26,250 Because this scan next line comes after a next int, it's going to get skipped. 112 00:06:26,990 --> 00:06:31,070 So as I stepped over it, it did not actually prompt me to enter anything. 113 00:06:31,070 --> 00:06:36,680 But if I step over this skin next line, it's actually going to wait for me so that it can scan for 114 00:06:36,680 --> 00:06:37,640 a string value. 115 00:06:37,640 --> 00:06:40,550 So I will enter in a name of Tim. 116 00:06:42,820 --> 00:06:48,340 Scanned up next line picks up our string value, and that string value gets stored in a string variable 117 00:06:48,340 --> 00:06:48,940 name. 118 00:06:49,300 --> 00:06:55,600 And now in this conditional, it's checking if my savings is greater than or equal to 10,000. 119 00:06:55,630 --> 00:07:00,370 If debt is smaller than 5000, and if the number of years worked is over. 120 00:07:00,370 --> 00:07:00,960 Two. 121 00:07:00,970 --> 00:07:04,510 It's really beautiful that I can see my values side by side. 122 00:07:04,510 --> 00:07:07,390 20,000 is greater than or equal to 10,000. 123 00:07:07,600 --> 00:07:13,300 My debt is smaller than 5000 and I have worked for more than two years. 124 00:07:13,300 --> 00:07:19,960 So this expression is going to evaluate to true and running the code inside. 125 00:07:20,560 --> 00:07:22,300 Congratulations, Tim. 126 00:07:22,300 --> 00:07:24,130 You have been approved. 127 00:07:24,520 --> 00:07:29,020 All right, Now, what if I do not meet the requirements? 128 00:07:29,020 --> 00:07:30,520 Let's try this out again. 129 00:07:33,540 --> 00:07:36,690 The press continue to continue to the next breakpoint. 130 00:07:36,870 --> 00:07:38,520 Are you here to get a mortgage? 131 00:07:38,700 --> 00:07:40,080 We'll say yes. 132 00:07:40,790 --> 00:07:42,140 Yes equals yes. 133 00:07:42,140 --> 00:07:45,050 This this evaluates to true will step over. 134 00:07:46,890 --> 00:07:55,020 We'll put in a savings of, let's say, 5000, which is less than 10,000 and a debt of 2000. 135 00:07:57,790 --> 00:07:58,540 So scanned. 136 00:07:58,540 --> 00:08:01,780 Our next double picks up the first double that we input. 137 00:08:01,780 --> 00:08:05,740 And after I step over this line it will scan for the next double. 138 00:08:05,740 --> 00:08:10,930 That's the limited by white space, picking it up, storing it in a depth variable. 139 00:08:10,960 --> 00:08:12,850 How many years have you worked for? 140 00:08:12,850 --> 00:08:18,670 Will print this after stepping over the next end, it's going to prompt me to enter an integer. 141 00:08:18,700 --> 00:08:20,500 I'm going to say three years. 142 00:08:21,900 --> 00:08:23,130 What is your name? 143 00:08:23,700 --> 00:08:25,710 This next line is going to get skipped. 144 00:08:25,710 --> 00:08:28,770 It will get wasted because it comes after a next int. 145 00:08:30,280 --> 00:08:33,730 This next line will actually prompt me to enter in a string. 146 00:08:33,760 --> 00:08:36,010 We will say once again, Tim. 147 00:08:37,559 --> 00:08:43,350 Submitting it to him gets picked up and then stored in a name string. 148 00:08:45,180 --> 00:08:50,250 And now, conveniently, I can visualize my variables right beside the conditions. 149 00:08:50,250 --> 00:08:53,850 So the debt is smaller than 5000. 150 00:08:53,850 --> 00:08:55,080 This one is good. 151 00:08:55,080 --> 00:08:57,420 The years is bigger than two. 152 00:08:57,450 --> 00:08:58,530 This one is good. 153 00:08:58,530 --> 00:09:05,910 However, the savings is not greater than or equal to 10,000 because we're using the end logical operator. 154 00:09:05,910 --> 00:09:11,820 All of these need to be true for the whole expression to be true, but because one of them is false, 155 00:09:11,850 --> 00:09:14,880 this entire expression is going to be false. 156 00:09:14,880 --> 00:09:17,070 The if statement will not run. 157 00:09:17,070 --> 00:09:20,130 And what's actually going to run is the LL statements. 158 00:09:20,670 --> 00:09:21,450 All right. 159 00:09:21,450 --> 00:09:22,110 Sorry. 160 00:09:22,110 --> 00:09:24,240 You are not eligible for a mortgage. 161 00:09:24,240 --> 00:09:31,320 You did not meet all the requirements and now I can press continue so that execution can resume and 162 00:09:31,320 --> 00:09:33,600 the program will terminate naturally. 163 00:09:33,930 --> 00:09:34,770 All right. 164 00:09:34,770 --> 00:09:36,300 That is all. 165 00:09:36,330 --> 00:09:39,750 I really hope you enjoyed these breakpoint sessions. 166 00:09:40,050 --> 00:09:44,400 The one thing I really wanted to drive home was how easy it is to visualize. 167 00:09:44,400 --> 00:09:50,010 And if else, all you have to do is put one breakpoint in the beginning and then keep pressing. 168 00:09:50,010 --> 00:09:50,970 Step over. 169 00:09:52,060 --> 00:09:56,500 But if you just want to navigate from one breakpoint to another, then you can press the button. 170 00:09:56,500 --> 00:09:57,310 Continue. 171 00:09:57,730 --> 00:09:58,180 All right. 172 00:09:58,180 --> 00:09:58,870 That is all.