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

Prompt the user with the question "Do you understand do while loops?" Store the result in a new String variable named re

What am I supposed to do here?

Example.java
// I have initialized a java.io.Console for you. It is in a variable named console.

9 Answers

Brody Ricketts
Brody Ricketts
15,612 Points

Joey Sadowski

You're getting an error when using Grigorij Schleifer code because its not what the question is asking you to do. Think of it as a repeat after me exercise, if they said "Do you understand do while loops?", and you said "Do you understand do/while loops?", you're not exactly repeating after them.

These challenges are sensitive in a way that you MUST do what the task is asking you to do, specifically when storing strings or variable names.

What you are suppose to do here is store a console.readLine() into a string variable named response. It will look kind of like this

String response = console.readLine("....");
// Place what the task told you to ask the user inside the double quotes
Brody Ricketts
Brody Ricketts
15,612 Points

Just to show you what I got when copying code:

String inputFromUser = console.readLine("Do you understand the do/while Loop?  ");

Bummer! Did you create a new String called response?

So I adjusted the String variable to be called response:

String response = console.readLine("Do you understand the do/while Loop?  ");

Bummer! You need to use console.readLine to ask 'Do you understand while loops?'

Do you see what the task is asking you to do now?

I am still having trouble with Q1 (Prompt the user with the question "Do you understand do while loops?" Store the result in a new String variable named response.) I put in your code and I still get "Bummer"!!!!

The answer is:

String response = console.readLine("Do you understand do while Loops? ");

Grigorij Schleifer
Grigorij Schleifer
10,365 Points

Here you dont need to create a new object of the Console class because the console object is already defined for you and you can use console.readLine() to store an Input in a String. You dont need to create console

Console console = System.console();

instead you use this

String inputFromUser = console.readLine("Do you understabnd the do/while Loop?  ");

If you want a do/while-loop that is asking the user, whether he understands ít. You can do it this way

do{
String inputFromUser = console.readLine("Do you understabnd the do/while Loop?  ");
 // "yes" or "no" is stored in the inputFromUser variable 
// when the user types "no" the loop repeats,  when  "yes" the loop is over
}while(inputFromUser .equalsIgnoreCase("no"));
Chris Cherenegar
Chris Cherenegar
321 Points

It is critical that when typing code, things must be typed perfectly. There were several mistakes including the variable name.

String response = console.readLine("Do you understand do while Loops? ");

Grigorij Schleifer
Grigorij Schleifer
10,365 Points

Sorry boys,

i didnt wont to confuse anyone. Just tried to explain the logic behind the challenge :)

Muhammad Asif
PLUS
Muhammad Asif
Courses Plus Student 557 Points

String response; do { response = console.readLine("Do you understand the do/while Loop? "); } while (response.equalsIgnoreCase("no"));

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