assert Exercises |
< Previous Next > |
final int MAX_LOOP_COUNT = 10; final int COUNTER_THRESHOLD = 50; int i = 0; int counter = 0; while( i < MAX_LOOP_COUNT ){ int j = 0; while( j < MAX_LOOP_COUNT ){ ++counter; if( counter > 50 ){ return; } ++j; } ++i; } // Should never reach this line /* add assert statement HERE */
/** * Processes the survey results * @param name Participant's last name * @param age Participant's age * @return true if survey results were successful processed, false otherwise */ private boolean processSurvey( String name, int age ){ // Note: It's assumed that the name is at least 2 characters long // Note: Can only legally process participants 18 years and older }