Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C++ program that (1) reads a string, (2) replaces every occurrence of th

ID: 3541128 • Letter: W

Question

Write a C++ program that

    (1) reads a string,
    (2) replaces every occurrence of the substring "C++" by a string "Java",
    (3) converts every alphabet in the string to upper case, and
    (4) output the final string.

   For example, if the input is:
       I love C++! C++ is fun.
   after replacing "C++" by "Java", it becomes
       I love Java! Java is fun.
   after converting each alphabet to upper case, it becomes
       I LOVE JAVA! JAVA IS FUN.

   You are only allowed to call the following string functions:
    length: get the number of chars in the string
    substr: get a specified substring
    find:   find the position of a substring
    []:     accessing a char at a specific position in the string.
            In other words, a string can be viewed and accessed as an array of chars.
    str1 = str2;  copy the string str2 to the string str1
    str = str1 + str2; concatenate str1 and str2, and save it to str.
*/

#include <iostream>
#include <string>

using namespace std;

int main( )
{
    string    original;      //contains input string
    string    modified;    //the string obtained by replacing "C++" with "Java"
    string    upperStr;    //convert chars in the string "modified" to upper case
    int        pos;        //the starting position of the substr "C++"
    

    getline(cin, original);

    Write a code segment that (1) copy the string to modified and upperStr, (2) replaces every occurrence of the substring "C++" by a string "Java", (3) converts every alphabet in the string to upper case, and (4) output the final strings. (this step is done already)
    
    cout << "The original string is: " << original << endl
         << "After replacing C++ with Java: " << modified << endl
         << "Converting to upper case: " << upperStr << endl;
         
    return 0;
}
     
    

Explanation / Answer

http://www.chegg.com/homework-help/questions-and-answers/i-need-help-finish-program-problem-description-write-program-1-reads-string-2-replaces-occ-q920542 check this link..

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote