Text Variables
A group of problems that help you to practice declaring, assigning, and using variables with a type of text.Declare a Text Variable
Declare two text variables in this program. The first variable should be named firstName
and the second should be named lastName
. When you are ready run the program. Fix any errors if you happen to get any.
Assign a Value to a Text Variable
Now that you have declared variables to store a first and last name, add the two assignment blocks to the program in the correct location. Then replace the text values with a made up character's first and last name so they match the correct variable. Then run your program and check the output window for the character's first and last name.
Using Output and Text Variables
Choose and edit the correct blocks from the tray so that when the program runs it displays the values of the first and last name variables. Be sure to use two output blocks.
The output should be the following:
Rowan
Smith
Common Naming Errors
Run this program with three common naming errors and fix each error. Once all three errors are fixed the program will run and it will output the name, Rowan Smith.
Block Order
Read through and run this program. Then move the output blocks so that the other first and last names become the program output.
The following is the correct program output:
Elijah
Williams
Common Errors with Matching Quotes
Run this program with two existing matching quote errors and fix each error. Once the program is corrected it will output the name, Rowan Smith.
Declare and Assign in One
Combine the process of declaring and assigning a text variable into one block. The blocks that do this are already in the tray. Use them to output the name, Rowan Smith.
Concatenate with Text Variables
Change the existing code so the program displays the first and last names on one line. Use the concatenation operator(i.e. +) to format and ouptut the full name. You will also need to add a space between the first and last names.
Your output should look like the following:
Rowan Smith
A Different Solution
This time write a program that outputs a character's name on one line, but solve the problem in a slightly different way. Use and modify each of the three block in the tray to declare the firstName, lastName, and fullName variables. Instead of using concatenation in the output block, use it in the fullName variable block.