Question
Inputs: 1. (char) An incorrectly formatted book title Outputs: 1. (char) A correctly formatted book title Background: You love fiction books. You also love to
Inputs:
1. (char) An incorrectly formatted book title Outputs:
1. (char) A correctly formatted book title
Background:
You love fiction books. You also love to recommend your favorite books to your friends. But you also realize that you are too lazy to properly format the title of your favorite books by hand. You decide to create a MATLAB function to do it for you.
Function Description:
To generate the correctly formatted title of a book, follow these rules:
-
Capitalize the first letter of each word unless they are the following words: 'and', 'the', 'of'.
-
The first letter of the character vector should always be capitalized, even if it is 'and', 'the', or 'of'.
Example:
unformatted = 'THe OLd MaN AND tHe sEa'; formatted = fixBookTitle(unformatted); formatted 'The Old Man and the Sea'
Notes:
-
All words will be separated by a space.
-
The words 'and', 'the', and 'of' will not appear at the beginning of other words.
Hints:
-
Remember that the first letter of a word follows a space except when the words is the first word in the string.
-
strfind() will always return the index of the first letter of the string you are trying to find.
-
Think of how you can combine the upper() and lower() functions with indexing to capitalize or lowercase a singular or set of letters.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started