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

  What are different modes of circuit and packet-switched

Companies are looking at many options to get better service for their telecommunications needs. What are different modes of circuit and packet-switched networks? What are the common types of methods for using these networks, such as DSL, ATM, and so ..

  What are some of the unique features that become available

What are some of the unique features that become available when either the forest or the domain is changed to the 2008 functional level? What about 2008 R2? What features are lost when moving to either of the 2008 functional levels?

  Explain how to complete team roles inventory

To do this, well complete Team Roles Inventory. After you have completed inventory, what roles are you most probable to play? How do these roles compare with other?

  Describe why analyst needs to understand how people think

Describe why an analyst requires to understand how people think, how they learn, how they react to change, how they communicate, and how they work.

  Pc that used to operate correctly displays a message

A PC that used to operate correctly displays a message, BOOTMGR is missing. Research this problem and make a list of possible reasons why a PC could report this error

  How to deal with each type of known attack

Include Denial of Service attacks, Spoofing, Replays, TCP Session Hijacking, and Attacks on Encrypted Data (such as passwords).

  Describe how upper is adjusted to allow simpler code to work

Describe how A_upper is adjusted to allow this simpler code to work. (Hint: A_upper requires to be adjusted because A_lower will be sign-extended.)

  Write a method firstlast that could be added

Write a method firstLast that could be added to the LinkedIntList class that moves the first element of the list to the back end of the list. Suppose a LinkedIntList variable named list stores the following elements from front (left) to back (right)

  Produce a diagram of a proposed network

Produce a diagram of a proposed network

  Design an algorithm determining the total purchases

Design an algorithm determining the total purchases

  Design a database application to keep track of movies

Design a database application to keep track of movies, actors, and the roles played by actors in movies. You may make up all the data.

  Degrees in fahrenheit

They need a program that will convert Fahrenheit to Celsius. The user will enter the degrees in Fahrenheit and the program will give the results in Celsius.

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