Lab 11 - Working with strings and arrays

Now that we have a bit of experience working with strings and arrays, let’s set up a problem that is fairly typical of things you might need to do in the “real” world (wherever that is!)

Setting up an array of strings

Set up a program with an array of strings holding the names of a few (5 will do) of your friends, or anonymous folks if you like. Make all of their names be lower case, something like “fred flintstone”

Build data arrays for name parts

Create two more arrays of strings, one named “first”, and one named “last”. Do not initialize these two arrays.

Break up your name strings

Now write code that breaks your name strings into two parts. You guessed it, into a first name and a last name part. You will need to explore the string documentation to find a “method” that will do this job. Store your set of names in the appropriate arrays, in the same order as in your first array. (If names[0] holds “fred flintstone”, then first[0] will hold “fred” and last]0] will hold “flintstone”

Print out the list of names, one name per line. Each line should show the original name, followed by the first name and the last name with a space between each name.

Now, add code to capitalize the first letter of each string in the first and last arrays.

Finally, print out your new list of names, this time in last name, comma, first name order. This list should be capitalized as we expect it to be!

What to turn in

Submit your final code to Blackboard as usual.