Print 'censored' if userinput contains the word 'darn', else print userinput. end with

3 answers
Question:

Print "censored" if userinput contains the word "darn", else print userinput. end with newline. ex: if userinput is "that darn cat.", then output is: censoredex: if userinput is "dang, that was scary! ", then output is: dang, that was scary! note: if the submitted code has an 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); int ispresent = userinput. find("darn"); if (ispresent > 0){cout < < "censored" < < endl; /* your solution goes here */return 0; }

Answers

#include <string>

#include <iostream>

using namespace std;

int main() {

string userInput;

getline(cin, userInput);

// Here, an integer variable is declared to find that the user entered string consist of word darn or not

int isPresent = userInput.find("darn");

if (isPresent > 0){

cout << "Censored" << endl;

// Solution starts here

else

{

cout << userInput << endl;

}

// End of solution

return 0;

}

// End of Program

The proposed solution added an else statement to the code

This will enable the program to print the userInput if userInput doesn't contain the word darn

answer; i believe the correct answer is network?

a local network will allow everyone in the office to share the printer.

Similar Solved Works

4 answers

Which of the following are properties of hydrocarbons? answer hydrophilic, a good source of stored energy,

Which of the following are properties of hydrocarbons? answer hydrophilic, a good source of stored energy, and consisting primarily of carbon and hydrogen hydrophobic, nonpolar, and a good source of stored energy hydrophobic, polar, and charged hydrophobic, containing numerous amine groups, and pol...
3 answers

Tamara is selling candy bars to support her school’s soccer team. On the graph here, the x-values represent the number of candy

Tamara is selling candy bars to support her school’s soccer team. On the graph here, the x-values represent the number of candy bars sold, and the y-values represent the total amount earned from selling those candy bars. According to the graph, if Tamara earns $20 for the team from selling candy b...
4 answers

Acertain factory building has an old lighting system. lighting the building currently costs, on average,

Acertain factory building has an old lighting system. lighting the building currently costs, on average, $20,000 a year. a lighting consultant tells the factory supervisor that the lighting bill can be reduced to $8,000 a year if $50,000 is invested in new lighting in the building. if the new lighti...
10 answers

WHO WANTS TO PLAY QUIZZIZ?WHOEVER WINS GET MY ACCOUNT AND IT HAS 90889 POINTS!!!Subject: Christmas Quizif you dont play, free pointsjoinmyquiz. comCode:

WHO WANTS TO PLAY QUIZZIZ? WHOEVER WINS GET MY ACCOUNT AND IT HAS 90889 POINTS!!! Subject: Christmas Quiz if you dont play, free points joinmyquiz. com Code: 586833...
3 answers

Determine the terminal point for 3pi/4 .

Determine the terminal point for 3pi/4 ....
5 answers

Help pls bro pls

Help pls bro pls [tex]Help plssss bro plsssssssssss[/tex]...
2 answers

Reread the section in The Devil and Tom Walker in which he Devil and Tom set out the terms of their working agreement. Identify the one activity the Devil

Reread the section in The Devil and Tom Walker in which he Devil and Tom set out the terms of their working agreement. Identify the one activity the Devil asks of Tom that Tom refuses. Write a brief essay to explain what this refusal by Tom reflects about the social and moral beliefs of Washington I...
3 answers

The speeds of vehicles on a highway with speed limit 100 km/h are normally distributed with mean 114 km/h and standard deviation

The speeds of vehicles on a highway with speed limit 100 km/h are normally distributed with mean 114 km/h and standard deviation 8 km/h. (Round your answers to two decimal places.) ((a) What is the probability that a randomly chosen vehicle is traveling at a legal speed? % (b) If police are instruct...
4 answers

Nthe circle shown, bc is the diameter and mab = 120°. what is the m< abc​

Nthe circle shown, bc is the diameter and mab = 120°. what is the m< abc​...
10 answers

In which number is the value of the 7 ten times greater than the value of the 7 in 307,214?

In which number is the value of the 7 ten times greater than the value of the 7 in 307,214?...
6 answers

Pencils are sold in boxes of 10. Erasers are sold in boxes of 14. A teacher wants to buy the same number of pencils and erasers.

Pencils are sold in boxes of 10. Erasers are sold in boxes of 14. A teacher wants to buy the same number of pencils and erasers. Work out the smallest number of boxes of each item she should buy....
8 answers

Aline’s slope is −16. the line passes through the point (6,2). find an equation for this line in both slope-intercept

Aline’s slope is −16. the line passes through the point (6,2). find an equation for this line in both slope-intercept form and point-slope form using the given point. an equation for this line in slope-intercept form is: . an equation for this line in point-slope form is:...
4 answers

13.3.2 Test (CST): Force und MotionQuestion 7 of 8Which diagram describes an object moving at a constant

13.3.2 Test (CST): Force und Motion Question 7 of 8 Which diagram describes an object moving at a constant speed? Distance versus Time 300 250 200 O A Distance (km) 150 100 50 24 Time (h) Velocity versus Time o Velocity (mph) 12 3 4 5 6 7 Time PREVIOUS...
4 answers

Translate 'it's a good opportunity' into french. c'est une bonne chance. c'est une bonne occasion. c'est

Translate "it's a good opportunity" into french. c'est une bonne chance. c'est une bonne occasion. c'est une bonne opportunité. b or c...
6 answers

Choose all the factors of 5. (Check all that apply.)41325

Choose all the factors of 5. (Check all that apply.) 4 1 3 2 5...
6 answers

Pls solve the last box i don’t understand it. thnx : )

Pls solve the last box i don’t understand it. thnx : ) [tex]Pls solve the last box i don’t understand it. thnx : )[/tex]...
2 answers

Do you think the vietnam declaration of independence was valid? why?please help

Do you think the vietnam declaration of independence was valid? why? please help...
3 answers

Consider an economy that produces only two goods: fresh apricots and dried apricots. In this economy,

Consider an economy that produces only two goods: fresh apricots and dried apricots. In this economy, the technology of producing dried apricots is to place fresh apricots on special racks and allow them to dry in the sun. Fannie's Farms is the only company that grows fresh apricots, while Darryl's ...
4 answers

List foods associated with salmonella, E. coli and listeria.

List foods associated with salmonella, E. coli and listeria....
3 answers

The concentration of salt water is found to be 18%. What is the mass of the salt if the mass of the water is 200 g? A. 18 g B.

The concentration of salt water is found to be 18%. What is the mass of the salt if the mass of the water is 200 g? A. 18 g B. 36 g C. 218 g D. 182 g...

-- 0.012546--