Please enable JavaScript to use CodeHS

AP Computer Science A (Mocha)

Lesson 2.10 While Loops

Description

Just like in Karel, Java has while loops. While loops are a way to repeat a block of code so long as some condition remains true. The condition is written in the form of a boolean expression. As long as the boolean expression remains true, code within the while loop will be executed. The moment that the boolean expression becomes false, code outside of the while loop will be executed; the loop is done.


Objective

Students will be able to…

  • Explain the purpose of a while loop
  • Create while loops to repeat code while a condition is true
  • Utilize while loops to solve new types of problems

Activities

These are all the activities included in the lesson

2.10.1 While Loops
2.10.2 While Loops
2.10.3 While Loop Countdown
2.10.4 Making Taffy