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

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

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