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
Vitalij Kacanovskij
1,851 PointsLast Homework: Guys asking for your help. I really don't understand do I have some mistakes, or I am doing everythingbad
String response = console.readLine ("Do you understand do while loops? ");
String response;
do {
String response = console.readLine ("Do you understand do while loops? ");
boolean isInvalidWord = console.printf (response.equalsIgnoreCase("No"));
if (isInvalidWord) {
console.printf("Asnwer is incorect try again ");
}
1 Answer
Diego van Schie
373 PointsOkay, so I see you're struggling with scopes(The squirly braces). Here's a cool trick. Start at the beginning of this code "do {" and start there. Now, go letter by letter and if you find a "{" add 1 to your score. But, everytime you find a "}" you remove 1 from your score. At the end, your score should be 0.
Here's a test:
do {
int a = 5;
int b = 3;
while (b < a) {
b++;
console.printf(b);
}
You should count 1. This is an error because you didn't end at 0, and you haven't balanced out your squigly braces.
Now, do it in your code, and record what you get.
I counted: 1. Here's your error. You're not balancing out the braces, and so java sees this: {{ }. Java doesn't like that. It needs to be even. Now, there's another error. You need to add a "while" clause. This is quite frankly difficult to explain here, so I suggest you watch a tutorial on treehouse, and if you still don't understand it look on YouTube.
Thank you :)