Java Java Basics Perfecting the Prototype Looping until the value passes

Chris Garavente
Chris Garavente
315 Points

how to finish the do while loop exercise by saying you passed the test

Hi all,

I'm trying to figure out where I went wrong on the third part of this exercise and I can't figure out what I need to be inputting to get the results I want.

Thanks in advance for any help,

Example.java
// I have initialized a java.io.Console for you. It is in a variable named console.
String response = console.readLine("Do you understand do while loops?  ");
boolean isInvalidWord;
do {
  response = console.readLine("Do you understand do while loops?  ");
  isInvalidWord = (response.equalsIgnoreCase("no"));
  if (isInvalidWord) {
    console.printf("Do you understand do while loops? \n\n");
  }
} while(isInvalidWord);
String correctresponse = console.readLine("Do you understand do while loops?  ");
do {
  response = console.readLine("Do you understand do while loops?  ");
  correctResponse = (response.equalsIgnoreCase("yes"));
 if (correctResponse.equalsIgnoreCase("yes")); {
   console.printf("Because you said yes, you passed the test!  ");
 }
} while(correctResponse);

1 Answer

Steven Parker
Steven Parker
203,717 Points

There should only be one loop for all tasks of this challenge. And there should only be one "readLine" call, from task 2 on it should be inside the loop.

The final message added in task 3 will go after the loop. Be sure to include the actual response given as part of the output string.

Chris Garavente
Chris Garavente
315 Points

thanks so much for your response - really helped.