Menu

(Solved) : Inputs 1 Char Incorrectly Formatted Book Title Outputs 1 Char Correctly Formatted Book Tit Q44063271 . . .

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 favoritebooks to your friends. But you also realize that you are too lazyto properly format the title of your favorite books by hand. Youdecide to create a MATLAB function to do it for you.

Function Description:

To generate the correctly formatted title of a book, followthese rules:

  1. Capitalize the first letter of each word unless they are thefollowing words: ​’and’​, ​’the’​, ‘of’​.

  2. The first letter of the character vector should always becapitalized, even if it is ​’and’​, ‘the’​, or ​’of’​.

Example:

unformatted = ‘THe OLd MaN AND tHe sEa’; formatted =fixBookTitle(unformatted); formatted → ‘The Old Man and theSea’

Notes:

  • ● All words will be separated by a space.

  • ● The words ​’and’​, ​’the’​, and ​’of’ ​will not appear at thebeginning of other words.

    Hints:

  • ● Remember that the first letter of a word follows a spaceexcept when the words is the first word in the string.

  • ● strfind() will always return the index of the first letter ofthe 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 orset of letters.

Expert Answer


Answer to Inputs: 1. (​char​) An incorrectly formatted book title Outputs: 1. (​char​) A correctly formatted book title Ba…

OR