Using your understanding of variable assignments, StandardIn class, Scanner class, and loops. Make an application that asks the user if they would like to hear a knock-knock joke. If the User indicates they would like to hear the joke then have the program proceed to tell the user a knock-knock joke.
The program must stop and wait for the user to respond. For example, the application should wait for the user to respond with “Who’s there” when it initially says “Knock Knock”. It should also wait for the user to reply to the second response as well.
The program should treat the response “who’s there” the same as “WHo’s theRE”
The program should be able to understand an incorrect input for instance if it’s expecting “who’s there?” but receives “what is there?” or something erroneous, it should notify the user to try again and wait for the proper response to continue the joke, it should keep doing this until the proper response is received.
You can find knock-knock jokes (https://thoughtcatalog.com/melanie-berliet/2015/09/40-ridiculous-knock-knock-jokes-thatll-get-you-a-laugh-on-demand/)
Acceptable User Input
Your
program should be able to accept any of the following responses from
the user in response to the first “knock knock” prompt:
“who’s there?”, “who’s there”, “whos there?”, “whos there”, “who are you?”, “who are you”
The next response is a little bit more tricky as your application is expecting a response that depends on the prompt. Take a look at the example below.
0 – Program: Knock knock
1 – User: Who’s there?
2 – Program: Cow
3 – User: Cow who?
4 – Program: No cows say moooo!
The program is expecting a response from the user to be what they said in the prompt on line 2 appended with the word “who”. Thus application should accept any of the following inputs:
promptText+” who?”, promptText+” who?”
Terminal Messages
When
this process starts it should print on a sperate line the string
“__Starting Knock Knock__”
When
this process end it should print on a sperate line the string
“__Terminating Knock Knock__”
Step 2) Keep Telling Jokes
Create a program that keeps telling the user a joke. Consecutive jokes cannot be the same. The joke must follow a question and answer format. For example:
Computer: “What’s the difference between a snowman and a snow-woman?”
User: “Idk what?”
Computer: “Snow Balls”
The program must ask the user if they would like to keep going after each joke. And if the user says no the program should say goodbye and terminate. Otherwise, the program should continue on its next joke.
The program should be able to tell a minimum of 20 different jokes. The program should be able to accept more than 3 different responses to the initial joke question, example “Idk what?”, “you tell me”, “I don’t know what?”, etc.
You can find Q&A jokes here
Acceptable User Input
Your program should be able to accept any of the following responses from the user in response to the first prompt:
“idk”, “I dont know”, “You tell me”, “I give up”, “Yell me now”
Your
program should be able to accept any of the following responses from
the user in response to the second prompt regarding
continuation:
Yes responses could be any of the following: “y”, “yup”, “yes”, “keep going”, “one more”, “another”
No response could be any of the following: “n”, “nope”, “no”, “stop”, “quit”, “no more”
Terminal Messages
When
this process starts it should print on a sperate line the string
“__Starting Repeat Jokes__”
When
this process end it should print on a sperate line the
string “__Terminating Repeat Jokes__”
In
either step, if the user does not type in the correct input program
should print the string “I
don’t understand your input. Please try again”.