This may be a difficult thing to do so for anyone to ACTUALLY answer this you migghttt want to up the amount of points you get for answering maybe, 20-40 points.
If you're coding with C++ then the solution would be:
if (userInput.find("darn") != -1) {
cout << "Censored" << endl;
}
else{
cout << userInput << endl;
}
Keep in mind that this will reject any input with the word "darn" in the sentence. This will not filter the word darn if the capitalization is in different formats like "Darn, dArn, daRn, darN, DARN".
Answer:
There is logic problem in condition of elseif statement that is (time<20).
Explanation:
elseif(time<20) will be true for time<10 that means program will never greet good morning as to make logic correct either change condition from <em>elseif(time<20)</em> to <em>elseif(time<20&& time>=10)</em>. Or change the order of condition like check first for <em>elseif(time<10) </em>
solution 1
if (time < 6) { greeting = "It is too early!"; }
else if (time < 20 && time>=10) { greeting = "Good Day!"; }
else if (time < 10) { greeting = "Good Morning!"; }
else { greeting = "Good Evening!"; }
console.log(greeting);
solution 2
if (time < 6) { greeting = "It is too early!"; }
else if (time < 10) { greeting = "Good Morning!"; }
else if (time < 20 ) { greeting = "Good Day!"; }
else { greeting = "Good Evening!"; }
console.log(greeting);