I hope you had fun building the chat, but if you solve that, you're on fire.
If you had trouble, no worries.
Here's what I did.
First, we have to set up scanner to scan for values.
So I'm going to start by importing scanner from the Java util package.
Then I'm going to say scanner.
Schenn.
Is equal to a new instance of scanner that can receive input from the system system in.
And now the first input needs to be a string, so we're going to use scan next line to pick it up and
then we're going to store whatever the user inputs inside a variable called name string name.
All right, now in the reply, we're going to replace the name Placeholder with the value inside our
variable name.
And now the next input is also going to be a string, so Scandi next line will pick up the next string.
And you're going to store the string input inside the variable home string home and now in the reply,
we can replace the home placeholder with the value inside home.
And now the next input needs to be an integer, so we're going to use scan next and to pick up the next
integer int age is equal to scanned next int.
And now to realize they're going to follow this answer in the first reply.
We're going to replace the age placeholder with the age variable.
And for the second placeholder, we're going to divide the users age from 400.
Now, you might be thinking, whoa, whoa, we're performing a division operation between two integers.
That's not good.
Well, in this case, we don't really care about decimals.
Whether Java board is 20 times or twenty point two times older than me doesn't really matter in this
context.
It would actually be better not to have any decimals.
Now, if you remember in the instructions, I warned you to be careful from the next line trap.
The reason I said this is because we're going to have to use next line to pick up the next string.
But if you put a next line ahead of a next and and next double or a next long, in a way, this next
line is going to get skipped.
Let me show you what I mean.
We're going to say string language is equal to Scandi next line.
And we're going to compile the code.
Put in some values.
Do you see what I mean?
It's almost like the next line is just ignored, it's wasted on something else.
You might be wondering why this happens.
I'll explain what's going on once we cover delimiters in the next section booleans and conditionals.
For now, the simple solution is to add a throwaway next line before the real next line.
That way, the next line that we don't care about gets skipped and we get to use it the next one.
Now, if you test their code, everything should work.
We're going to compile compiler code.
Put in some values.
And there you are, Trappe avoided.
Now, in the next reply, replace the language placeholder with the language variable.
And now, if you followed every instruction, your output should look like this.
Everything runs well, but the output is really messy.
The screaming cat is telling us to add a line of spacing between each answer and reply.
So before I reply, we're just going to add a new line of space, you can do this by adding again at
the beginning of each reply.
And now, after each reply, JAV is going to print a new line before printing the string.
So if we were to honor code now, this is what we'd have.
That being said, I hope you had fun building the chat, but now you're ready for the next section.