Step 2 - Read the user's name
Best first step is to build something small, then we can grow the program our from that start. Let’s just get the first two messages handled - reading the user’s name and displaying it. So we want to see this at the end:
-
Open your terminal, and setup your project
-
Add the using directives to access the SplashKit and Convert code.
-
At this point you should just have these two lines of code.
As you look at this you want to see if there are any values that will change. We will need to create variables to store these.
Looking at the first lines, I imagine that we may have different users run this. So their name may change.
-
-
Add the code to create a
name
variable - then we can think about how we use this. -
Review the messages we want to output. To start we want to output the message
"What is your name: "
, read the text and user enters, then output a blank line and the greeting text"Hi "
followed by the user’s name.Looking back at the terminal methods, we have methods to output text (
Write
andWriteLine
), and read text from the user (ReadLine
). Use these to display the prompt, and output the required messages. -
-
Now compile and run the program to see the output. Check it against what we were aiming to achieve.