Question: In this weeks lab, you will create a tool in which a user can enter a string (up to 25 characters) and choose how they
In this weeks lab, you will create a tool in which a user can enter a string (up to 25 characters) and choose how they wish to manipulate the string from a menu your program will display (see the run-through). The program will continue to ask for commands until the user enters the quit command. The commands are:
Replace All If a user types replace all using ANY sort of capitalization, your program will prompt the user to enter the character to change and the new character. Afterwards, it will replace all instances of 2 the first character with the new character and will printout the new string. This method does change the original sentence entered.
Quit If the user types quit with any sort of capitalization, the program will stop running.
Note: Examples of capitalizations to consider are ALL CAPS, all lowercase, or mIxED CapITAlIzAtIon.
For this lab, you need to make sure your program can gracefully handle user errors. That is, simply stating An error occurred does not help a user recover from a mistake. Specific errors your program should be capable of fixing (not a complete list) are:
If the user enters a character that does not exist within the string, your program should display an error and prompt them for the next command.
Case matters within the run of each command. If a user requests that the letter q get replaced, your program should not replace any capital Q letters.
If the user enters an invalid command, you should display an error message and ask for a valid command.
% prompt: ./a.out
Enter a string (up to 25 characters) to be transformed: Go Tigers
Enter your command (quit, replace all): REPLACE ALL
Enter the character to replace: e
Enter the new character: 3
Your new sentence is: Go Tig3rs
Enter your command (quit, replace all): replace some aaaaaaaaaaaaa12341234
Sorry, that command is invalid. Please type one of the options.
Enter your command (quit, replace all): replace all
Enter the character to replace: i
Enter the new character: 1
Your new sentence is: Go T1g3rs
Enter your command (quit, replace all): rePLace ALL
Enter the character to replace: q
Error, q is not in the string.
Enter your command (quit, replace all): QUIT % prompt:
Write a program called string_manipulator.c that accomplishes the requirements listed earlier in this assignment. Additional program specifications include:
Your main should not manipulate any strings or do any tasks aside from gathering user input, and calling functions as needed.
Your program should include a function called replaceAll that replaces all characters in the input string with the desired new character. This is the only place where any sort of string manipulation should occur. You are responsible for writing the complete declaration and implementation of this function. You can choose to implement this function above your main, or afterwards with a declaration above the main. This function can take any parameters you deem appropriate.
Once the program starts, all error messages should display helpful messages and then re-prompt the user with the choices (as shown in the sample run through). Your handling of all possible user input cases is being graded more heavily on this assignment than previously. (See the rubric).
Your output formatting should mimic the sample output provided in this document. Do not add extra spacing or change the wording.
CAN'T USE GETS FUNCTION
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
