Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using C++, complete the following program. It is important that you follow the directions carefully and that your output matches the sample output below. Please

Using C++, complete the following program. It is important that you follow the directions carefully and that your output matches the sample output below. Please include a screenshot of your output. The main function shouldn't be more than a couple lines long, and the whole program shouldn't be more than two pages long.

This is a not an ordinary Pig Latin. Write a program that reads a sentence as input and converts each word from English to Pig Latin. In this version, to convert a word to Pig Latin you first convert user input to upper case, find the substring GH if there is one, and remove the rest of the c-string include GH. Then you append the c-string ay to the end of the word. Here are some examples:

English:

night

Pig Latin:

niay

English:

niGHt

Pig Latin:

niay

English:

No G H here

Pig Latin:

NO "G - H" HEREay

Repeat until user has entered a QUIT (regardless of case). You are required to use c-strings for this program.

Functions:

Main function should be shorter than half a page.

Function header

Explanation

void convertToUpper(char * str)

This function should covert the given c-string to upper cases

void findAndRemove(char* str)

This function should find the substring GH in the given c-string, and remove the rest of the c-string include GH

void appendAy(char* str)

This function should only be called when you have successfully removed GH and the remaining string. Append a ay (lower case) towards the end of the c-string.

void convertPigLatin(char * str)

This function should provide a do-while loop (or a while loop) to convert user input to upper case first, then calls findAndRemove and appendAy in that order. Notice your program should stop as soon as user has entered a quit message regardless of the case (e.g. Quit is acceptable). Display a message Over! when the process is finished.

Hints:

ay will be attached to the end of the c-string regardless

No inputs are longer than 180 characters, guaranteed.

No input validation needed.

Sample Output:

Please enter a string, enter quit to stop the process:

night

NIay

Please enter a string, enter quit to stop the process:

niGHT

NIay

Please enter a string, enter quit to stop the process:

No "G - H" here

NO "G - H" HEREay

Please enter a string, enter quit to stop the process:

First they ignore you, then they laugh at you, then they fight you, then you win.

FIRST THEY IGNORE YOU, THEN THEY LAUay

Please enter a string, enter quit to stop the process:

then they fight you, then you win.

THEN THEY FIay

Please enter a string, enter quit to stop the process:

QUIT

Over!

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

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions

Question

3. Are our bosses always right? If not, what should we do?

Answered: 1 week ago