Java Java Basics Perfecting the Prototype Looping until the value passes


I don't know what's wrong with my coding in second line
// I have initialized a for you. It is in a variable named console.
String response = console.readLine  ("Do you understand do while loops?") ;
response.equalsIgnoreCase ("No") ;

2 Answers

First of all, it's a good idea to declare the response string outside the loop. String response;

Secondly, it was correct that you used the response.equalsIgnoreCase("No"). What you did miss was to create the actual loop and down below you can find it.

do {
response = console.readLine ("Do you understand do while loops?"); }
while (response.equalsIgnoreCase("No"));

Hope it helps!

Bastian Petersson
Bastian Petersson
9,164 Points

It looks like you are trying to update the variable in code. However, the "console.readLine()" method asks for an input in the terminal and not in the code itself.

You are asked to store the response in a variable called "response". Firstly you have to define that variable but not initialize it. On the next line, use the "console.readLine()" method to put the user input into the new variable.

This is how i would do it:

String response;
response = console.readLine("Do you understand do while loops?");

Keep up the good work!