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

Print \"Censored\" if userInput contains the word \"darn\", else print userInput

ID: 3674637 • Letter: P

Question

Print "Censored" if userInput contains the word "darn", else print userInput. End with newline. Note: These activities may test code with different test values. This activity will perform three tests, with userInput of "That darn cat.", then with "Dang, that was scary!", then with "I'm darning your socks.". See How to Use zyBooks. Also 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.

Explanation / Answer

#include <iostream>
#include <string>
using namespace std;ac


int main() {
   string userInput;

   userInput = "That darsn cat.";

   /* Your solution goes here */
   int isPresent = userInput.find("darn");

   if (isPresent > 0){
       cout << "Censored" << endl;
   }

   else{
       cout << userInput << endl;
   }


  

   return 0;
}


output

That darsn cat

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