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

  A discussion of the information used in the system

A full description of the new system, a description of its components, and the benefit it will provide to Riordan• A discussion of the business requirements driving the need for the system• A discussion of the information used in the system

  The acquisition of software is complex for various reasons

The acquisition of software is complex for various reasons: an organization may have any number of software applications, which keep changing over time

  Write an isr in c to add the signed value on port t (ptt)

Write an ISR, in C, to add the signed value on PORT T (PTT) to the byte value stored in location data1.

  In how many different ways can one plan such a tour

The price of a European tour includes four stopovers to be selected from among 10 cities. In how many different ways can one plan such a tour if the order of the stopover matters.

  Gaussian elimination

The solution should be the vector x and flag which takes a value of 0 if the algorithm was executed completely and 1 if it wasn't.

  Describe how to use d

Suppose you have two nonempty stacks S and T and a deque D. Describe how to use D so that S stores all the elements of T below all of its original elements, with both sets of elements still in their original order.

  Determine size of one minute mono audio file

Digital audio transducer samples real sound at the rate of 40 kHz and assigns 8 bits to each sample. Determine the size of one minute mono audio file?

  Full subtractor

Show that a full subtractor can be implemented using a "Full Adder" device and two inverter gates - For this, you will have to create a "Full Adder" device (Note: you can use the idea of what you built in question 2)

  Write a program perform using mars - assembly language

Write a program which will perform the following " using MARS - Assembly language" a. Read in a string from the user b

  Describe how the referential integrity restrict

Describe how the referential integrity restrict, cascade, and set-to-null delete rules operate in a relational database

  You mentioned normalization to cassia

In your discussion of the systems design phase, you mentioned normalization to Cassia. She would like you to explain the basics of normalization in plain English to help her understand the data design tasks.

  The leading business organizations

Boardman Management Group is one of the leading business organizations of today's time. They are planning to make a resort, Baderman Island Resort. The overall organization is vastly spread in number of countries. It has numerous branches in al..

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