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 trialSomak Sengupta
Courses Plus Student 779 Pointswhats the problem with my code
bummer : coming did you put prompting code in a do while block that is checking to see if (' whoequals.IgnoreCase("banana")?
/* 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?
...as long as Person A has answered Banana the above repeats endlessly
...assuming the person answers Orange we'd see
Person B: Orange who?
...and then the punchline.
Person A: Orange you glad I didn't say Banana again?
(It's a really bad joke that makes it sound like "Aren't you glad I didn't say Banana again?")
Let's just assume the only two words passed in from the console from Person B are either banana or orange.
*/
// ====BEGIN PROMPTING CODE====
// Person A asks:
console.printf("Knock Knock.\n");
// Person B asks and Person A's response is stored in the String who:
// Person B responds:
String who;
do { who = console.readLine("Who's there? ");
console.printf("%s who?\n", who);
if (who.equalsIgnoreCase("banana"))
{ console.printf("banana who");}
}
while( who.equalsIgnoreCase("orange"));
console.printf( "Orange you glad I didn't say Banana again?");
// ==== END PROMPTING CODE ====
2 Answers
Somak Sengupta
Courses Plus Student 779 Pointsyes and no because the moment I read the question(in the forum) I realized the problem was with my thinking not my code and I knew exactly what to do. Thanks a lot. problem solved
Steve Hunter
57,712 PointsOK - I'll close it off as answered anyway.
Steve.
Somak Sengupta
Courses Plus Student 779 PointsSomak Sengupta
Courses Plus Student 779 Pointsthanks a lot
Steve Hunter
57,712 PointsSteve Hunter
57,712 PointsDid that work for you?
Steve.