Question

In: Computer Science

THE NOT REPLACE PROBLEM Must use loops. Please do not use sequence of if statements. I...

THE NOT REPLACE PROBLEM

Must use loops. Please do not use sequence of if statements.

I need it in C++.

Given an input string, set result to a string where every appearance of the lowercase word "is" has been replaced with "is not". The word "is" should not be immediately preceded or followed by a letter -- so for example the "is" in "this" does not count.  

• for input of "is test" → "is not test"

• for input of "is-is" → "is not-is not"

• for input of "This is right" → "This is not right"

Solutions

Expert Solution

PROGRAM :

#include <iostream>
#include <string>
// importing regex module for regular expression
#include <regex>

using namespace std;

int main() {
string text;
cout << "Please enter the input string : ";
// getline() to input a string ot a sentence
getline(cin,text);
// \b acts as word boundary
// regex variable 'e' is initialized based on the question which matches for 'is' inside any statement
std::regex e("\\b(is)\\b");
// replace 'is' with 'is not'
cout<<"The replaced string is : " + std::regex_replace(text,e,"is not");
}

OUTPUT :


Related Solutions

THE STRING MATCH PROBLEM C++ only. Must use loops. Please do not use sequence of if...
THE STRING MATCH PROBLEM C++ only. Must use loops. Please do not use sequence of if statements. . Given 2 strings, a and b, set result to the number of the positions where they contain the same length 2 substring. So "xxcaazz" and "xxbaaz" yields 3, since the "xx", "aa", and "az" substrings appear in the same place in both strings. • for input of "xxcaazz", "xxbaaz" → 3 • for input of "abc", "abc" → 2 • for input...
CODE MUST BE IN C++ (please use for loop) write a program that loops a number...
CODE MUST BE IN C++ (please use for loop) write a program that loops a number from 1 to 10 thousand and keeps updating a count variable (count variable starts at 0 ) according to these rules: n1 = 14 n2 = 54 n3 = 123 if the number is divisible by n1, increase count by 1 if the number is divisible by n2, increase count by 2 if the number is divisible by n3, increase count by 3 if...
C++ Please Do not use loops!! Assignment : Dice Roll Redux In "Dungeons & Dragons" and...
C++ Please Do not use loops!! Assignment : Dice Roll Redux In "Dungeons & Dragons" and similar role-playing games, dice with different numbers of sides are used to determine the outcomes of events throughout the game. There are different dice for different occasions: 4-sided, 6-, 8-, 10-, 12-, and 20-sided dice are common. A required roll is typically designated <n>d<s> where <n> is the number of dice to throw and <s> is the number of sides on those dice. For...
please do this in C++! I want to understand it, it must be done before the...
please do this in C++! I want to understand it, it must be done before the evening or nightime. Follow instructions exactly as it says. Please send a screenshot also with your code so I can see how it is supposed to be formatted. Since typing it a chegg answer, makes it look a bit messy. Your program will read in a file of commands. There are three types of commands: Warrior creates a new warrior with the specified name...
Please do the math by hand, do not use a program, I need to see the...
Please do the math by hand, do not use a program, I need to see the procedure, the answer itself is less important. Comparison of peak expiratory flow rate (PEFR) before and after a walk on a cold winter's day for a random sample of 9 asthmatics. Use the following data to determine if the patients conditioned changed after a walk. Present your results and make some interpretations. Subject Before After 1 312 300 2 242 201 3 340 232...
In the given instruction, I am to use while loops only. The goal is to prompt...
In the given instruction, I am to use while loops only. The goal is to prompt the user to select an acceptable input. If the wrong input is given, the program forces the user to select an appropriate input. The program also keeps running until the user chooses to exist by selecting a very specific input which in my case is the upper or lower case "E". The problem is even after selecting upper or lower case "E", my program...
Ali has 100 jobs that he must do in sequence, with the times required to do...
Ali has 100 jobs that he must do in sequence, with the times required to do each of these jobs being independent random variables with mean 1.3 minutes and standard deviation 3.0 minutes. Aysun has 200 jobs that she must do in sequence, with the times required to do each of these jobs being independent random variables with mean 1.0 minutes and standard deviation 2.3 minutes. Note that the time required for Ali to do any of his jobs is...
Do it in python please! also please use this template please I have provided and below...
Do it in python please! also please use this template please I have provided and below is the activity def main(): # import the module random try: # asking the user to enter a number between 1 and 100 #loop time while if elif #for loop # generates that number of random integers and stores them in a list for x in # computations # displays the results on the screen # call try_Again to give the user the opportunity...
How can I make a problem like this simpler? and what equation do I use for...
How can I make a problem like this simpler? and what equation do I use for part D? Thanks! A researcher wonders if mental simulation will help one more successfully achieve one’s goals. To test this idea, the researcher recruited six students from a general psychology class, several weeks before their first midterm. After their first midterm, the researcher got the students’ scores on this test from their professor. Several weeks later, each of the students was brought into the...
dont use loops for it and each problem solving process needs a seperate statement within a...
dont use loops for it and each problem solving process needs a seperate statement within a function. also create a range for each of the functions to limit input to the max points for each section. also make a dictionary to associate names with student id and hard code some examples in there to return string with students name, their id number, total score, and lab number using python You will be writing a program that can be used to...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT