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 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

Chase Marchione
Chase Marchione
155,055 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!