CS12
Assignment 2
Due: 11:59 PM Monday May 8
In this assignment, you must use string functions wherever possible. You will not receive full credit if you do not use string functions.
Assignment Tasks
Write a function that takes a string and a word and ouputs the string with all occurrences of that word underlined. For example, if the string were "the dog ran to the man" and the word was "the", the function should output:
the dog ran to the man --- ---
Write a function that takes a string and two words. Your function should then replace all occurrences of the first word with the second word and then output the new string. For example, if the string were "the dog ran to the man", the word to be replaced was "the" and the word to replace with was "a", your function should output:
a dog ran to a man
Remember, replacement words could be longer or shorter than the word they are replacing. Be sure to test both situations and do not just pad characters positions with spaces.
Write a program that prompts the user for the name of a file. This file will contain a series of sentences, each on a separate line. Read a sentence from the file. Now give the user the following options:
Remember to use proper coding style and use appropriate comments in your code. You should get this started early as this assignment might require you to research some additional string functions. You can use these manual pages as a reference of what string functions are available to you and a brief description of how to use them. Also, remember you can use the mailing list, TA's, and Office Hours for help.