1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Galina-37 [17]
3 years ago
9

Print "Censored" if userInput contains the word "darn", else print userInput. End with a newline. Ex: If userInput is "That darn

cat.", then output is: Censored Ex: If userInput is "Dang, that was scary!", then output is: Dang, that was scary! Note: If the submitted code has out-of-range access, the system will stop running the code after a few seconds, and report "Program end never reached." The system doesn't print the test case that caused the reported message.
#include
#include
using namespace std;
int main() {
string userInput;
getline(cin, userInput);
/* Your solution goes here */
return 0;
}
Computers and Technology
1 answer:
Gemiola [76]3 years ago
6 0

Answer:

<em>The program goes as follows</em>

<em>Comments are used to explain difficult lines</em>

#include <iostream>

#include <string>

using namespace std;

int main()

{

string userinput;

getline(cin,userinput);

/* My Solution starts here*/

//Initialize sub string position to 0

int stringpos = 0;

// Declare an iterating variable to iterate through userinput

int startpos;  

//Declare and initialize a determinant variable

int k = 0;

while((startpos = userinput.find("darn",stringpos))!=string::npos)

{

 //If userinput contaings "darn", increase k by 1

k++;

// Go to next string position

stringpos = startpos+1;  

}

//If determinant variable k is p then, userinput does not contain "darn"

if(k==0)

{

 cout<<userinput;

}

//Otherwise, it contains "darn"

else

{

 cout<<"Censored";

}

/* My Solution ends here*/

return 0;

}

See attached for .cpp program file

Download cpp
You might be interested in
Firms attempt to maximize their revenue by producing more product at ______ prices.
mixas84 [53]
The answer is C, higher.
4 0
3 years ago
Explain the information processing cycle and give examples
strojnjashka [21]
Information processing cycle - Computer Definition. The sequence of events in processing information, which includes (1) input, (2) processing, (3) storage and (4) output. The input stage can be further broken down into acquisition, data entry and validation.

That's all I got. Hope that helped a little (:
5 0
4 years ago
Is the adoption rate of communication technology increasing ?
Neko [114]
More people adopt the technology during any period, leading to an increasing rate of adoption. So, yes
3 0
4 years ago
Read 2 more answers
What the central difference between negative and positive politeness?
tiny-mole [99]

Answer:

Negative politeness is often used to make a request seem less infringing as people assess threatening aspects of communication using three components: Social distance, Relative power. Absolute ranking.

6 0
3 years ago
Read 2 more answers
How does Kelvin inspire other
fomenos

Answer:

hard work and creative thinking can solve all problomes

Explanation:

4 0
3 years ago
Other questions:
  • A patient asks her doctor to send a copy of her records to another medical office. However, the records are not transmitted beca
    10·2 answers
  • Write a Python program where the user enters the number of elements in a list ‘n’ and those ‘n’ numbers that form the list. The
    13·1 answer
  • Which is a tool that allows you to copy formatting from one place and apply it to other places?
    9·1 answer
  • How does Wireshark differ from NetWitness Investigator?
    6·1 answer
  • I need help with this
    12·1 answer
  • Write a for loop to print all NUM_VALS elements of array hourlyTemp. Separate elements with a comma and space. Ex: If hourlyTemp
    11·1 answer
  • Software (often on firmware) designed to make physical products and devices smarter by doing things like sharing usage informati
    6·1 answer
  • What is word wrapping??
    5·1 answer
  • if you were determining what was expected of you simply by looking at media, what messages would you take away?
    8·2 answers
  • What do you call a collection of pre-programmed commands and functions used in programs?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!