Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Write a C++ program that translates C strings from English into Pig Latin.

Pig Latin is a form of coded language used for amusement. Many variations exists, so, use the following rules for translation:

  • If a word begins with a consonant (which we define as a letter other than a, e, i, o, or u), move the leading consonants to the end of the word and add "ay" ("ball" becomes "allbay" and "phone" becomes "onephay").
  • If a word begins with a vowel (a, e, i, o, or u), add "way" to the end of the word. ("all" becomes "allway" and "one" becomes "oneway").
  • If a word consist only of consonants, just add "ay" ("crypt" becomes "cryptay").
  • If a letter in a word other than the first letter is upper case, the word is left unchanged and not translated (e.g., "BRuin" and "ALWAYS" are not translated).
  • If in a word an apostrophe appears with a letter to its right and left (e.g., "can't") the word is left unchanged and not translated.

Words can contain alphabetic characters and apostrophes; however an apostrophe must have a letter on both sides of it to be part of a word. In case of capitalization in the English word (only with the first letter of the word), you need to capitalize the first letter of the newly formed Pig Latin word (e.g. "Bruin" becomes "Uinbray" ).

You must write the function:

int translate(char str[], int maxLength);

This function takes a C string str and modifies it to create its Pig Latin version. The function returns the number of words succesfully translated. If at any time translating a word would cause you to overrun the size of the C-string discontinue translating str and return the number of words translated up to that point. You should use the maxLength parameter as the maximum number of characters in your string (not including the null byte).

Your translate function and any functions you write that it calls must not use any std::string objects. If you need to use a string, you must use a C string. (Although the program you turn in must not use any C++ strings, only C strings, you might want to consider this development strategy: Ignore this restriction at first, and develop a working solution that uses C++ strings. After you've ironed out the issues in writing project, save a backup, and then convert your calls using C++ strings to using C strings instead. This approach helps you avoid confusing the mistakes in your use of C strings with the mistakes in your algorithm, so makes debugging easier.)

The translate function is the only function you are required to write. You may write additional functions as part of your solution if you wish. While we won't test those additional functions separately, their use may help you structure your program more readably. Of course, to test all your functions, you'll want to write a main routine that calls your translate function. During the course of developing your solution, you might change that main routine many times. As long as your main routine compiles correctly when you turn in your solution, it doesn't matter what it does, since we will rename it to something harmless and never call it (because we will supply our own main routine to throroughly test your translate function).

Your translate function and any functions it calls must not cause anything to be read from cin. If you want these functions to write things out for debugging purposes, write to cerr instead of cout. When we test your program, we will cause everything written to cerr to be discarded instead - we will never see that output, so you may leave those debugging output statements in your program if you wish.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91376263
  • Price:- $50

Guranteed 36 Hours Delivery, In Price:- $50

Have any Question?


Related Questions in Computer Engineering

From a security standpoint do you believe the apple

From a security standpoint, do you believe the Apple approach of hiding permissions or the Android approach of requiring the user to accept application permissions is a better approach? Why do you feel this way and do yo ...

Terry amp sons makes bearings for autos the production

Terry & Sons makes bearings for autos. The production system involves two independent processing machines so that each bearing passes through these two processes. The probability that the first processing machine is not ...

Suppose that the wall street journal reports that we are

Suppose that the Wall Street Journal reports that we are headed for a recession. You are the manager of a firm that produces Starcho Lunch. Your marketing research people tell you that the demand for your product is give ...

Run the huffman coding algorithm on the following

Run the Huffman coding algorithm on the following input: Alphabet C = {p, r, a, i, s, e, d}, with frequencies f as percentages= {12, 16, 16, 12, 16, 16, 12}. Draw the optimal coding tree and the (weighted) average code l ...

In what kind of economy is a central planning board or

In what kind of economy is a central planning board or commission typically used to answer the basic economic questions?

Assignmenta in the slides and textbook one of the examples

Assignment (a) In the slides and textbook, one of the examples features a class for counting up. An interface which defines this functionality is given below: public interface IncrementCounter { //Increments the counter ...

In reconnaissance provide three different methods or means

In Reconnaissance Provide three different methods or means to locate information about your target. What sorts of information would you expect to obtain using each source? What might you use the information obtained from ...

Question suppose that x 00271 and y 608 are correctly

Question : Suppose that x* = 0.0271 and y* = 6.08 are correctly rounded versions of x and y to 3 digit mantissas. The smallest interval [a,b] that would contain x is [0.02705, 0.02715] since 0.0271 is between those numbe ...

Jeff decides to start saving some money from this upcoming

Jeff decides to start saving some money from this upcoming month onwards. He decides to save only $500 at first, but each month he will increase the amount invested by $100. He will do it for 60 months (including the fir ...

Systems analysis projectpersonal trainer inc owns and

Systems analysis project Personal Trainer, Inc. owns and operates fitness centers in a dozen Midwestern cities. The centers have done well, and the company is planning an international expansion by opening a new "superce ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As