Java Java Basics Perfecting the Prototype Looping until the value passes

Do while loop exercise 2 of 3. Error yet I am not getting any preview results.

String response = "true"; boolean isNo; console.readLine("Do you understand do while loops? "); do { isNo = response.equals("No"); if (isNo) { console.readLine("Try again. "); } }

Example.java
// I have initialized a java.io.Console for you. It is in a variable named console.
String response = "true";
boolean isNo;
  console.readLine("Do you understand do while loops?  ");
do {
  isNo = response.equals("No"); 
  if (isNo) {
    console.readLine("Try again.  ");
  }
} while(isNo);

1 Answer

Malcom T.L Musuma
Malcom T.L Musuma
8,227 Points

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

Hello, that worked for me👆. So you are required to prompt the user with a question(the 'do' part) as long as the response they typed in is No(the 'while' part)