Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Michael V. Mannino

3rd Edition

0071107010, 978-0071107013

More Books

Students also viewed these Databases questions

Question

how can your leader best support you in your career development?

Answered: 1 week ago