Question

In: Computer Science

Create a C++ project called RobberyLanguage. Ask the user to enter a word. Write a function...

Create a C++ project called RobberyLanguage. Ask the user to enter a word. Write a function that will receive the word, use the word to compile a new word in Robbery language and return the new Robbery language word. In the function: Use a while loop and a newline character (‘\0’) to step through the characters in the original string. How to compile a word in Robbery language: Double each consonant and put the letter ‘o’ between the two consonants. For example:" ENTER THE WORD: Welcome

original word is welcome , Robbery language: wowelolcocomome

process returned 0 (0*0) execution time :

press any key to continue "

Example of the definition of the function: string compileRobLanWord(char word[50]) Hints: Declare a new character string for the Robbery language word. A word in Robbery language has more characters than the original word. Therefor the new string must have its own index value. How it looks like in memory: Original word: S a m \0 2 0 1 2 3 Robbery language: S o S a m o m \0 0 1 2 3 4 5 6 7 Note: Remember to add the \0 character as the last character of the new word. In the main function: Example of the call statement in the main function: newWord = compileRobLanWord(word); Display the original word and the Robbery language word.

C#(VISUAL STUDIO)

Solutions

Expert Solution

#include<iostream>
#include<sstream>
#include<string>
using namespace std;

// FUNCTION PROTOTYPES
string compileRobLanWord(char word[50]);
bool isAlphabet(char c);
bool isConsonant(char c);

int main()
{
   char origWord[50];
   string robberyWord;
   cout << "ENTER THE WORD: ";
   cin >> origWord;
   robberyWord = compileRobLanWord(origWord);
   cout << "\nOriginal word is: " << origWord << endl;
   cout << "Robbery language is: " << robberyWord << endl;
   return 0;
}

// FUNCTION IMPLEMENTATIONS
string compileRobLanWord(char word[50])
{
   string res = "";
   stringstream ss;
   for (int i = 0; i < 50; i++)
   {
       if (isAlphabet(word[i]))
       {
           if (isConsonant(word[i]))
           {
               ss << word[i] << 'o' << word[i];
           }
           else
           {
               ss << word[i];
           }
       }
   }
   res = ss.str();
   return res;
}
bool isAlphabet(char c)
{
   if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
       return true;
   else
       return false;
}
bool isConsonant(char c)
{
   if (c != 'A' && c != 'a' && c != 'E' && c != 'e' && c != 'I' && c != 'i' && c != 'O' && c != 'o' && c != 'U' && c != 'u')
       return true;
   else
       return false;
}

******************************************************* SCREENSHOT ********************************************************

CODE SCREENSHOTS :

CONSOLE OUTPUT :


Related Solutions

ARDUINO Create a function that will ask the user to enter the values for each of...
ARDUINO Create a function that will ask the user to enter the values for each of the three colors (red, green and blue) between 0 and 255. The function should check that the user does not enter a number bigger than 255 or smaller than 0. If this happens, the function should keep asking for a valid number.
Write C++ void function called averageTemperature() that asks the user to enter integers with a sentinel...
Write C++ void function called averageTemperature() that asks the user to enter integers with a sentinel value of -999 to stop entering numbers. Then average the numbers and print the average. You will need an int acculumator for the temperatures and an int acculumator for the number of temperatures entered. Use the accumulators to calculate the average which will need to be a decimal number. Call the function from the main() function.
Instructions Write a program in C++ that create a LookupNames project. In the main function: Ask...
Instructions Write a program in C++ that create a LookupNames project. In the main function: Ask the user to enter a number of names, X to quit input. Store the names in an array. Also use a counter variable to count the number of names entered. Write a function displayNames to display the names. The function must receive the array and the counter as parameters. Write a function called lookupNames. The function must receive the array and the counter as...
Create a console app c#. Using a List, ask the user to enter all of their...
Create a console app c#. Using a List, ask the user to enter all of their favorite things. Once they are done, randomly pick a value from the list and display it.
Q3) ​Write a main function to test your SortTriple will ask the user to enter the...
Q3) ​Write a main function to test your SortTriple will ask the user to enter the three values, then uses ​SortTriple ​to reorder the values if required. The main function should print the value in the correct order and a message to indicate if the values were in the correct order or not. ​[20 points] ● You are NOT allowed to use loops or arrays in your code​ ​[- 30 points] ● You are ​NOT​ allowed to use global variables....
Part 2 Write a C code to create a user defined function called RecArea that will...
Part 2 Write a C code to create a user defined function called RecArea that will calculate the area of a rectangle. Call the function to print the area of the rectangle on the screen. Note: The user will enter the length and width of a rectangle (decimal values, float) and you Part 3 (Continue on part 2) Create another user defined function called TriArea that will calculate the area of a triangle. Print the area of the rectangle on...
C++. Write a program that asks the user to enter a single word and outputs the...
C++. Write a program that asks the user to enter a single word and outputs the series of ICAO words that would be used to spell it out. The corresponding International Civil Aviation Organization alphabet or ICAO words are the words that pilots use when they need to spell something out over a noisy radio channel. See sample screen output for an example: Enter a word: program Phonetic version is: Papa Romeo Oscar Golf Romeo Alpha Mike The specific requirement...
C++ Write the C++ code for a void function that prompts the user to enter a...
C++ Write the C++ code for a void function that prompts the user to enter a name, and then stores the user's response in the string variable whose address is passed to the function. Name the function getName.
Write in C# please! Ask the user to enter all of their exam grades. Once they...
Write in C# please! Ask the user to enter all of their exam grades. Once they are done, calculate the minimum score, the maximum score and the average score for all of their scores. Perform this using at least 2 Loops (can be the same type of loop) and not any built in functions.
Write a program using C language that -ask the user to enter their name or any...
Write a program using C language that -ask the user to enter their name or any other string (must be able to handle multiple word strings) - capture the epoch time in seconds and the corresponding nanoseconds - ask the user to type in again what they entered previously - capture the epoch time in seconds and the corresponding nanoseconds -perform the appropriate mathematical calculations to see how long it took in seconds and nanoseconds (should show to 9 decimal...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT