Java Bootcamp – Workbooks and Challenges
)}
Variables (Challenge)

Chatbot

You're going to build an app that carries a simple conversation.

Open the challenge


From the Java-Bootcamp-Resources, open Challenge 2.

Screen Shot 2022-10-11 at 11.40.48 PM.png

1. Store each answer.


After each question, add code that picks up the user's answer and stores it.

Careful from the nextLine() trap


nextLine() Trap
PitfallnextLine() gets skipped when placed after nextInt() , nextDouble(), or nextLong().
SolutionAdd a throwaway nextLine() before the "real" nextLine().
ExplanationThe upcoming lesson on Delimiters will explain why this happens.

2. Update each reply.


Update each reply with the user's answer.

3. Run your code.


Why is the cat scared?

The screaming cat appears when something's wrong or looks bad. In this case, the output is very messy. There should be a line of spacing between each answer and reply (see arrows).

4. Add a new line


Before every reply, add a new line.

Follow the comments to guide your code.

Final output:

Good luck!


Associated Course: The Complete Java Development Bootcamp
Related Course: The Complete Spring Boot Development Bootcamp – Become a Java Web Developer

Feedback Summary
4.7
43 students
5

91%
4

2%
3

0%
2

0%
1

7%
Written Reviews
There are no written reviews yet.