Java Java Basics Perfecting the Prototype Looping until the value passes

Raquel Schmidt
Raquel Schmidt
402 Points

how to make a response outside of the do while loop.

having trouble
// I have initialized a for you. It is in a variable named console.
String question = console.readLine ("Do you understand do while loops");
String response = console.readLine ("no");
  question ("Do you understand do while loops");


1 Answer

Jeffery Haupt
Jeffery Haupt
UX Design Techdegree Student 18,898 Points

Hi Raquel,

I was able to go into the Code Challenge that you were on and figure out what was happening.

First, when you are declaring the two Strings question and response, you actually have one variable too many. What you need to do hear is to take the line you have for the variable question and just rename that response, but leave everything else.

Then we you set up your do...while loop, you just past that same response variable line in between the curly braces (except without the String declaration this time).

The while part of the do...while loop is where your condition goes. The syntax is while( some conditional statement ) if it is true, then the code between the braces runs again, if it is false the do...while loop ends.