Unit 02
Selection and Iteration
Build Magpie — a chatbot that reads what a person typed and answers it — and in doing so learn the two things that turn a list of instructions into a program that responds to the world: decisions, and repetition.
Every assignment filed under this unit, and where each one stands with your classes. The whole console →
- Counting the tripschecking
- Why the null check comes firstchecking
- Sequencing, selection, repetitionchecking
- At least, more than, underchecking
- The branch that never runschecking
- Same object, or same contentschecking
- Remainders, digits, and a maximumchecking
- How much work is thatchecking
- One method, three questionschecking
- FRQ · Sandwichchecking
- FRQ · Mirrorchecking
- FRQ · Shippingchecking
- FRQ · Leap yearchecking
- FRQ · Collatzchecking
- FRQ · First powerchecking
- FRQ · In rangechecking
- FRQ · Ticket pricechecking
- FRQ · Can ridechecking
- FRQ · Matcheschecking
- FRQ · Sum oddchecking
- FRQ · Reversechecking
- FRQ · GCDchecking
- FRQ · Pairschecking
- FRQ · Changechecking
- FRQ · Halvingschecking
- FRQ · Trianglechecking
- FRQ · Outsidechecking
- FRQ · Digital rootchecking
- FRQ · Fizz countchecking
- FRQ · Compresschecking
- FRQ · Has repeatchecking
- FRQ · Factorschecking
- FRQ · Occurrenceschecking
- FRQ · Savingschecking
- Quiz · Fogchecking
- Practice quiz · Stutterchecking
- Quiz make-up · Fogchecking
Computer Science in Java · members' unit
Selection and Iteration is behind a locked door
Units in Computer Science in Java are for people taking the course. Getting in takes a link or a key — signing in on its own doesn't do it.
What's in this unit · 34 min read
- The project · Magpie
- 2.1 · Algorithms That Decide and Repeat
- 2.2 · Boolean expressions
- 2.3 · if Statements
- 2.4 · Nested if Statements
- 2.5 · Compound Boolean expressions
- 2.6 · Equivalent Expressions and Comparing Objects
- 2.7 · while Loops
- 2.8 · for Loops
- 2.9 · Standard Loop Algorithms
- 2.10 · Standard String Algorithms
- 2.11 · Nested iteration
- 2.12 · Counting How Often Code Runs
- Finishing Magpie
- Where this goes next
39 quick checksannotated specimenstepperloop tracerchatbot sandboxtruth tables+2 more
1 Sign in
With your school Google account. This is how your work reaches the gradebook — it doesn't open the unit by itself.
Or buy it
Reading on your own, with no class? The course can be yours.
One payment, yours for as long as the course is offered. No account is needed to buy: sign in afterwards with the address you paid with.
A key unlocks this browser and keeps your progress here; signing in keeps it with you across devices. Either way the key itself is only ever checked as a hash. Manage all of this on your account, read what signing in stores, or go back to Computer Science in Java.
Sources
- College Board — AP Computer Science A Course and Exam Description, Effective Fall 2025
- Laurie White — Magpie Lab (AP Computer Science A lab series)