Challenge 25b

Description

The purpose of this challenge is to manually manipulate character arrays. This challenge “translates human to dog.”

Requirements

  1. Write a program to translate any entered string into a variation of the word “Woof”
  2. Define 2 character arrays: char human[100], dog[100]
  3. Ask the user to enter a string into human. Use cin.getline(human, 100) function call to get the string from the user in main.
  4. Create a function void translate(char human[], char dog[]). The function will take in text via the human parameter and pass the translated text via the dog parameter – remember that arrays can be modified inside of functions and setting the characters of dog will effectively change the array passed as that parameter. Think of the human parameter as the input and the dog parameter as the output
    1. Translate any one-character word as “w”
    2. Two-character word as “wf”
    3. Three-character words become “wof”
    4. Four-character words become “woof”
    5. 6-character words become “woooof”
    6. and so on, longer words will have a ‘w’ as the first character and an ‘f’ as the last character and however many o’s to have an equivalent resulting length. Make sure your code can  handle any word length up to  maximum allowed by the character array.
    7. Maintain the case as entered by the user. If the user enters “Hello” this becomes “Wooof”
  5. From main–not from inside the translate() function–display the translated message

Sample Interaction / Output

Enter a string: Hey
Wof

(run it again)
Enter a string: Hacker
Woooof

(run it again)
Enter a string: Inception 
Wooooooof

LEGEND
PROGRAM OUTPUT
USER INPUT
FROM INPUT

CATALOG ID: CPP-CHAL0025b

Print Requirements