Write a c++ program that translates c strings from english

Assignment Help Basic Computer Science
Reference no: EM13806283

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.

Reference no: EM13806283

Questions Cloud

Activities and processes to procure goods and services : This is the final draft to the best plan that was done previously... the requirements needed to have a successful practie plan: Articulates activities and processes to procure goods and services.
What do you think the arrows on the puck are illustrating : What do you think the arrows on the puck are illustrating - How do the arrows from the positive charges compare and contrast to the ones from the negative balls?
Summary concerning the specific article ssl encryption : Write a one-page summary concerning the specific article SSL Encryption - Securing Internet of Things (IoT) and explain how you think the issue affects network and/or global security in general. Do not forget to include the APA citation for the artic..
Delivery of the prototype from the vendor : One of the risks you anticipated for the project was the late delivery of the prototype from the vendor. You adjusted your project schedule to minimize the impact of the risk, built in a penalty for late delivery, and created action plans in case ..
Write a c++ program that translates c strings from english : 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..
Compute and display the geometric mean of all values : Use a loop with a sentinel to allow a user to enter arbitrary number of values. Compute and display the geometric mean of all values, excluding the sentinel. (Hint: Math.pow(x, 1.0/k) will compute the kth root of x)
What is the angle of incidence of light beam : A beam of light is reflected off a plane mirror at an angle of 50° relative to the surface.  What is the angle of incidence of this light beam?
Overcoming socioeconomic challenges : Overcoming Socioeconomic Challenges
Contractor officer request for a modification : In your opinion, can you justify the contractor officer's request for a modification? Why or why not? Explain in detail.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Introduction to information systems

Complete the On Your Own project (PC or Mac version) according to the project instructions and submit your assignment through the online course shell.

  Create an array of integers 10 elements long

Create an array of integers 10 elements long. ? Loop through this array (using its length value), assigning a random value between 0 and 100 (inclusive) to each element. Remember: random(100) returns a float and will never return 100.0.

  What are some of the benefits of providing text links

What are some of the benefits of providing text links in addition to graphical links. How can we improve on existing websites

  Abc company order inventory system

ABC Company Order Inventory System

  Excel independent projects

I have 10 excel independent projects .There all form the text " Microsof Office 2013 Excel : In Complete " I have all the info and the start files. Since they're relatively easy and less then a page on the majority of them. I have no knowledge wit..

  Write a program which includes a user defined function

write a program which includes a user defined function named Upper. The function is passed a single char. It will return 1 if the char is upper case, i.e. between 'A' and 'Z'. it will return 0 otherwise.

  Write a program to allow additional items and prices

Write a program to allow additional items and prices to be input by the user and added to the end of the Cowboy.txt. Include a method to terminate the process.

  Explaining method effective in cracking web passwords

More people are utilizing online shopping and banking. Explain one method that you believe is most effective in cracking Web passwords.

  Banner advertising on web sites trigger realization

Banner advertising on Web sites helps trigger realization that there is gap between reality and desired state which occurs in?

  Create an array of numbers filled by the random number

Create an array of numbers filled by the random number generator. Determine the smallest, largest, average, and calculate the standard deviation. Allow the client to pick the size of the array to be used and allow the client to repeat the process ..

  Defense in depth

Defense in Depth

  Write a java program for performing order matching

write a Java program for performing order matching according to the typical rules of a double auction system.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd