Write a program that converts a string to its Pig-Latin equivalent. To convert a string to Pig-Latin use the following algorithm: 1. If the string begins with a vowel, add "way" to the string. For...


Write a program that converts a string to its Pig-Latin equivalent. To convert a string to Pig-Latin use the following algorithm:


1. If the string begins with a vowel, add "way" to the string. For example, Pig-Latin for “apple” is “appleway.”


2. Otherwise, find the first occurrence of a vowel, move all the characters before the vowel to the end of the word, and add "ay". For example, Pig-Latin for “strong” is “ongstray” since the characters “str” occur before the first vowel.


Assume that vowels are a, e, i, o, and u. You’ll find it useful to write several functions to help in converting a string to its Pig-Latin equivalent. You’ll need to use string member functions substr, find, and length. You’ll also need to concatenate strings using +. Finally, to find the first vowel, you may find it useful to write a function that returns the minimum of two values. You’ll need to be careful with the value string::npos returned by the string member function find. Sample output for the program follows.



Nov 26, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here