1. Write a function that converts a phrase into pig Latin. A word is converted to pig Latin by removing the first character of the word, placing it at the back of the word, and adding the characters “ay” to the word. For example, “hello world” in pig Latin is “ellohay orldway.” Your function can assume that each word consists of at least two letters and that each word is separated by one space, with no punctuation marks.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter6: User-defined Functions
Section: Chapter Questions
Problem 17PE
icon
Related questions
Question

1. Write a function that converts a phrase into pig Latin. A word is converted
to pig Latin by removing the first character of the word, placing it at the
back of the word, and adding the characters “ay” to the word. For example,
“hello world” in pig Latin is “ellohay orldway.” Your function can assume
that each word consists of at least two letters and that each word is separated
by one space, with no punctuation marks.
2. Write a function that counts the occurrences of a word in a string. The
function should return an integer. Do not assume that just one space separates words and a string can contain punctuation. Write the function so
that it works with either a String argument or a StringBuilder object.
3. Write a function that takes a number, such as 52, and returns the number
as a word, as in fifty-two.
4. Write a subroutine that takes a simple sentence in noun-verb-object form
and parses the sentence into its different parts. For example, the sentence
“Mary walked the dog” is parsed into this:
Noun: Mary
Verb: walked
Object: the dog
This function should work with both String objects and StringBuilder
objects.

Expert Solution
steps

Step by step

Solved in 5 steps with 2 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning