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 trialMUZ140118 Cathrine Makuya
10,300 Pointsstage 3 challenge 1
Read the comments and code below. We want to move that prompting code into a do while loop. Wrap the code into a do while and check in the condition to see if who equals "banana" so the loop continues. Remember to move your who declaration outside the do block.
/* So the age old knock knock joke goes like this:
Person A: Knock Knock.
Person B: Who's there?
Person A: Banana
Person B: Banana who?
...This repeats until Person A answers Orange
Person A: Orange
Person B: Orange who?
Person A: Orange you glad I didn't say Banana again?
*/
//Here is the prompting code
console.printf("Knock Knock.\n");
String who = console.readLine("Who's there? ");
console.printf("%s who?\n", who);
String who
do{
if(who.equalIgnoreCase(banana))
console.printf("who equals to banana");
}
}while(who.equalIgnoreCase(banana))
2 Answers
Mario Blokland
19,750 PointsYou just posted the question and only changed a little bit. I would advise to not open another thread if you already opened one for same question (You already opened at least 6 threads today with the title stage 3 challenge 1). Otherwise others don't know what already has been answered and you may get same answers for the same topic.
I wouldn't mind but you always only copy/paste the exercise question with your code and that way you really won't learn anything.
MUZ140118 Cathrine Makuya
10,300 Pointsthanks .l made it
Rebecca Rich
Courses Plus Student 8,592 PointsDo you have any questions about the do-while blocks or things with the challenge that you got stuck on?
MUZ140118 Cathrine Makuya
10,300 PointsMUZ140118 Cathrine Makuya
10,300 Pointsl tried it did not work out
Mario Blokland
19,750 PointsMario Blokland
19,750 PointsIn your second last thread I answered you, that you should put the prompts within the do-while loop and some other things :-). But you haven't done that yet.
If you have problems with this exercise I think it's because others already answered the exercises before for you, so now you don't know what your current problem is and will be for the future exercises. Therefore it would be best imo to do the last exercises again yourself so you know what you may have missed.
This is just my opinion and no offense though :-).