Home / Expert Answers / Computer Science / use-c-output-should-look-like-this-nbsp-exercise-1-word-separator-write-a-program-that-ac-pa828

(Solved): Use C++ Output should look like this.   Exercise 1: Word Separator Write a program that ac ...



Exercise 1:
Word Separator
Write a program that accepts as input a sentence in which all of the words are run together, but t

Use C++

Test Case 2 Falled Show whats missing
Which exercise? \( \backslash n \)
1 ENTER
\( \backslash n \)
Enter a sentence (no spaOutput should look like this.

 

Exercise 1: Word Separator Write a program that accepts as input a sentence in which all of the words are run together, but the first character of each word is uppercase. Convert the sentence to a string in which the words are separated by spaces and only the first word starts with an uppercase letter. For example the string StopAndSmellTheRoses. would be converted to "Stop and smell the roses." Exercise 2: replaceSubstring Function Write a function named replaceSubstring. The function should accept three string object arguments. Let's call them string 1 , string 2 , and string 3 . It should search string 1 for all occurrences of string2. When it finds an occurrence of string2, it should replace it with string3. For example, suppose the three arguments have the following values: \( \begin{array}{ll}\text { string1: } & \text { "the dog jumped over the fence" } \\ \text { string2: } & \text { "the" } \\ \text { string3: } & \text { "that" }\end{array} \) With these three arguments, the function would return a string object with the value "that dog jumped over that fence." Demonstrate the function in a complete program. Note: There should be no cout statements within the function definition string replacesubstring(string 31 , string 32 , string 33 ); Test Case 2 Falled Show what's missing Which exercise? \( \backslash n \) 1 ENTER \( \backslash n \) Enter a sentence (no spaces, 1st letter of each word is uppercase): \( \backslash n \) ProgrammingIsFun!!! ENTER \( \backslash \mathbf{n} \) Programming is fun!!! \( \backslash n \) Test Case 3 Failed Show what's missing Which exercise? \( \backslash n \) 2 ENTER \( \backslash n \) Enter the main string: the dog jumped over the fence ENTER \( \backslash n \) Enter the string to replace: the ENTER \( \backslash \mathrm{n} \) Enter the replacement string: that ENTER \( \backslash n \) that dog jumped over that fence \( \backslash n \) \( \backslash n \)


We have an Answer from Expert

View Expert Answer

Expert Answer


#include #include #include using namespace std; string exercise1(char *myStr){ string outputStr=""; //loop each string
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe