1 00:00:00,780 --> 00:00:04,680 I hope you had fun building the chat, but if you solve that, you're on fire. 2 00:00:05,230 --> 00:00:06,520 If you had trouble, no worries. 3 00:00:06,540 --> 00:00:07,300 Here's what I did. 4 00:00:07,830 --> 00:00:10,320 First, we have to set up scanner to scan for values. 5 00:00:11,100 --> 00:00:14,940 So I'm going to start by importing scanner from the Java util package. 6 00:00:22,670 --> 00:00:24,290 Then I'm going to say scanner. 7 00:00:25,370 --> 00:00:26,090 Schenn. 8 00:00:27,700 --> 00:00:34,600 Is equal to a new instance of scanner that can receive input from the system system in. 9 00:00:39,750 --> 00:00:46,440 And now the first input needs to be a string, so we're going to use scan next line to pick it up and 10 00:00:46,440 --> 00:00:51,750 then we're going to store whatever the user inputs inside a variable called name string name. 11 00:00:53,180 --> 00:00:58,100 All right, now in the reply, we're going to replace the name Placeholder with the value inside our 12 00:00:58,100 --> 00:00:59,030 variable name. 13 00:01:06,810 --> 00:01:12,390 And now the next input is also going to be a string, so Scandi next line will pick up the next string. 14 00:01:13,840 --> 00:01:21,250 And you're going to store the string input inside the variable home string home and now in the reply, 15 00:01:21,250 --> 00:01:24,580 we can replace the home placeholder with the value inside home. 16 00:01:29,340 --> 00:01:34,410 And now the next input needs to be an integer, so we're going to use scan next and to pick up the next 17 00:01:34,410 --> 00:01:38,520 integer int age is equal to scanned next int. 18 00:01:40,860 --> 00:01:44,200 And now to realize they're going to follow this answer in the first reply. 19 00:01:44,220 --> 00:01:47,220 We're going to replace the age placeholder with the age variable. 20 00:01:53,360 --> 00:01:57,470 And for the second placeholder, we're going to divide the users age from 400. 21 00:01:59,000 --> 00:02:03,310 Now, you might be thinking, whoa, whoa, we're performing a division operation between two integers. 22 00:02:03,360 --> 00:02:04,190 That's not good. 23 00:02:04,880 --> 00:02:07,160 Well, in this case, we don't really care about decimals. 24 00:02:07,490 --> 00:02:12,620 Whether Java board is 20 times or twenty point two times older than me doesn't really matter in this 25 00:02:12,620 --> 00:02:13,280 context. 26 00:02:13,730 --> 00:02:16,220 It would actually be better not to have any decimals. 27 00:02:17,630 --> 00:02:21,870 Now, if you remember in the instructions, I warned you to be careful from the next line trap. 28 00:02:22,760 --> 00:02:26,840 The reason I said this is because we're going to have to use next line to pick up the next string. 29 00:02:27,170 --> 00:02:33,890 But if you put a next line ahead of a next and and next double or a next long, in a way, this next 30 00:02:33,890 --> 00:02:35,330 line is going to get skipped. 31 00:02:36,110 --> 00:02:37,130 Let me show you what I mean. 32 00:02:37,700 --> 00:02:42,350 We're going to say string language is equal to Scandi next line. 33 00:02:48,030 --> 00:02:49,650 And we're going to compile the code. 34 00:02:56,450 --> 00:02:57,920 Put in some values. 35 00:03:04,610 --> 00:03:05,660 Do you see what I mean? 36 00:03:05,820 --> 00:03:10,740 It's almost like the next line is just ignored, it's wasted on something else. 37 00:03:11,490 --> 00:03:13,540 You might be wondering why this happens. 38 00:03:13,560 --> 00:03:18,690 I'll explain what's going on once we cover delimiters in the next section booleans and conditionals. 39 00:03:19,050 --> 00:03:23,940 For now, the simple solution is to add a throwaway next line before the real next line. 40 00:03:26,880 --> 00:03:31,010 That way, the next line that we don't care about gets skipped and we get to use it the next one. 41 00:03:32,300 --> 00:03:34,250 Now, if you test their code, everything should work. 42 00:03:34,280 --> 00:03:35,540 We're going to compile compiler code. 43 00:03:40,140 --> 00:03:41,400 Put in some values. 44 00:03:45,390 --> 00:03:47,550 And there you are, Trappe avoided. 45 00:03:52,240 --> 00:03:56,770 Now, in the next reply, replace the language placeholder with the language variable. 46 00:04:19,839 --> 00:04:23,440 And now, if you followed every instruction, your output should look like this. 47 00:04:24,830 --> 00:04:27,260 Everything runs well, but the output is really messy. 48 00:04:27,650 --> 00:04:32,000 The screaming cat is telling us to add a line of spacing between each answer and reply. 49 00:04:37,020 --> 00:04:42,660 So before I reply, we're just going to add a new line of space, you can do this by adding again at 50 00:04:42,660 --> 00:04:43,950 the beginning of each reply. 51 00:04:52,000 --> 00:04:56,300 And now, after each reply, JAV is going to print a new line before printing the string. 52 00:04:56,830 --> 00:04:59,770 So if we were to honor code now, this is what we'd have. 53 00:05:01,330 --> 00:05:05,710 That being said, I hope you had fun building the chat, but now you're ready for the next section.