Hi, you haven't provided the programing language in which you need the code, I'll just explain how to do it using Python, and you can apply the same method for any programming language, pseudocode or flowchart.
Answer:
1 userInput = input("Please enter 'userInput':\\")
2 if "darn" in userInput.lower():
3 print("Censored")
4 else:
5 print(userInput\\)
Explanation line by line:
- Line one asked for the user input, and store the value in a variable called userInput. Inside the input function, you put some text to indicate to the user to enter something and \\ is the new line character.
- Line two checked if the word "darn" is in the user input, for this, we use the built-in function in. Because we don't know if the user inputs the word "darn" in upper case, lower case or a mix of both we use the method .lower() to change the user input to lowercase and make the validation (Python is case sensitive -> A is not equal to a).
- Line three prints the word "Censored" if and only if the word "darn" is in userInput.
- Line fourth allows going to line five if and only if the word "darn" is NOT in userInput.
- Finally, line five prints the word entered by the user if and only if the word "darn" in NOT in userInput.