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:

  1. Capitalize the first letter of each word unless they are the following words: 'and', 'the', 'of'.

  2. 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!