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

Java Basics

Finally, using console.printf print out a formatted string that says "Because you said <response>, you passed the test!"

Example.java
// I have initialized a java.io.Console for you. It is in a variable named console.
do { 
response = console.readLine("Do you understand do while loops?"); //the answer of the user will be stored/assigned from console into "response"
  } while(response.equalsIgnoreCase("no")); 
if(response.equals("yes")||response.equals("no")){
       response = console.readLine("Do you understand do while loops ?"); 
  console.printf("No");
} 
Grigorij Schleifer
Grigorij Schleifer
10,365 Points

Hey Jules,

how are you doing with the challenge ???

Grigorij

1 Answer

Grigorij Schleifer
Grigorij Schleifer
10,365 Points

Hey Jules,

I see you had a very hard time with this challenge:

See the explanation of Allan and me here:

[ https://teamtreehouse.com/community/java-basics-7 ]

And here the code that should do the trick:

// TASK 1
String response;
// move this line in the do block
// response = console.readLine("Do you understand do whle loops?");
// TASK 2
do {
  response = console.readLine("Do you understand do whle loops?");
}while(response.equalsIgnoreCase("No"));

// TASK 3

console.printf("Because you said %s, you passed the test!", response);

DonΒ΄t give up, you will make it !!!

Grigorij