Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Java Basics Perfecting the Prototype Looping until the value passes

I don't understand the question.

// I have initialized a java.io.Console for you. It is in a variable named console. String response; if(response.equals("Unindentified")){ console.printf("Do you understand do while loops?"); }

Example.java
// I have initialized a java.io.Console for you. It is in a variable named console.
String response;
if(response.equals("Unindentified")){
  console.printf("Do you understand do while loops?");
}
Grigorij Schleifer
Grigorij Schleifer
10,365 Points

Hi Shelae,

have you solved the challenge?

Do you need more help?

Grigorij

2 Answers

Hi Grigorij, I did not get a chance to complete yet. I was busy with my Java homework from my class at Ivy Tech Community College. My instructor there is not teaching or providing examples for our class. Can you help me? Thank you for helping me with this question. I did not know it was requesting a do while loop.

Grigorij Schleifer
Grigorij Schleifer
10,365 Points

You are very welcome !!!

Shout out, if you need help :)

Grigorij

Grigorij Schleifer
Grigorij Schleifer
10,365 Points

Hi Shelae,

I commented the code for you a bit:

For the first task you need to declare a String variable "response". You donΒ΄t need to create a do while loop first

String response;
//declare a variable 
response = console.readLine("Do you understand do while loops");
// use the readLine method to store the input in response

For the second task, you should create a do while loop and put the input method into do-block. If the condition inside the while block is true (input is equals NO), the statement inside the do block will be excecuted.

do {
response = console.readLine("Do you understand do while loops");
} while (response.equalsIgnoreCase("No"));
// while response from the user is No (condition is true)
// repeat the statement inside do-block

task 3

console.printf("Because you said %s, you passed the test", response);
//use the String formatter %s inside the printf method to print response

Let me know, if I you need more help :)

Grigorij