Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Objects (Retired) Delivering the MVP Determining if it is Solved

Samuel Mengistu
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Samuel Mengistu
Front End Web Development Techdegree Graduate 17,790 Points

while loop quiz. Can't figure out the answer to this quiz.

Okay, so we have a code version of a carnival based Dunk Tank. Please fill in the blanks with proper code for the while loop.

while (remainingTries_______ 0 ________ ________ dunkTank.isDunked()) { throwBall(); }

Could someone please help me solve this.

2 Answers

cm21
cm21
150,854 Points

The logic is that there are still tries remaining, and the ball hasn't been dunked yet. Therefore, the throwBall method should be called.

while (remainingTries > 0 && !dunkTank.isDunked()) { throwBall(); }

Hope this helps!