Popular Exercises

Exercises allow students to apply new material and practice programming.

Each exercise has been tested with students, but we welcome suggestions on our mailing list and in our Github repository.

We also welcome contributions – exercises, links, sample code, teaching hints, or grading scripts – and we'll pass on revenue your exercises generate. Get in touch to learn more.


Introduction to programming

Students will be exposed to some of the powerful ideas underlying programming. They'll also have the opportunity to think creatively, reason logically, and work collaboratively.

Name Concepts Status
One-player pong scratch, variables, objects Student approved

Entering and manipulating data

Students will be able to create, manipulate, and store data inside their programs. They'll also gain confidence in tracing through code inside a single method.

Name Concepts Status
Slippery slopes doubles, variables, basic math Student approved
Tricky dice ints, random, control statements Idea sketch
Titlecase strings, variables, string manipulation Polish needed
Casting spells on numbers int, double, casting Polish needed
Magic 8 ball random, arrays Student approved
Loop exercises strings, for loops, printing Student approved
Factorial project for loops, nested loops Student approved
FizzBuzz strings, for loops, mods, if statements Student approved
Statistics ints, basic math Student approved
Statistics and Histograms ints, basic math, strings, printing Student approved

Entering and manipulating data structures

Students will be able to create, manipulate, and store data inside arrays. They'll also gain confidence in tracing through those arrays.

Name Concepts Status
Array exercises basic math, arrays Student approved
Array fun basic math, arrays Student approved
Array fun with strings basic math, arrays, strings Student approved
Array practice numbers, loops, arrays Student approved

Writing functions

Students will be able to write functions/methods, and they'll gain confidence in tracing through control flow across multiple functions.

Name Concepts Status
Pythagorean Theorem doubles, variables, functions Student approved
Rock, Paper, Scissors random numbers, strings, user input Student approved
Compact data ints, arrays, methods Student approved
Scramble words strings, for loops, functions Student approved
Fractional Calculator string manipulation, user input Student approved
Bunnies for loops, recursion Student approved
Recursion exercises recursion, basic map, string manipulation Student approved

Writing functions that interact

Students will continue to write functions/methods, now with the added challenge of tracing through control flow across multiple function/methods.

Name Concepts Status
On a roll for loops, functions, arrays Student approved
Measuring that roll arrays, for loops, if statments Student approved
Scramble or remove strings, for loops, functions, arraylists Student approved
It's raining hailstones! if statements, while loops, logical operators Student approved
Car rentals if statements, for loops, strings, mods Student approved
Apple, cherry, or pumpkin? if statements, for loops, doubles, functions Student approved
Treasure hunt 2d arrays, if statements, for loops, printing Polish needed

Introducing classes

Students will experiment with classes as "conceptual containers," used to separate dissimilar parts of program, without writing their own classes.

Name Concepts Status
Caesar ciphers characters, strings, for loops Student approved
Do you need an umbrella? random, external classes, if statements Polish needed
Seating Charts arraylists, 2d arrays, for loops, if statements Student approved
Seating Charts 2 arraylists, 2d arrays, for loops, if statements Student approved
Input validation for loops, strings, java swing Student approved

Writing classes

Students will design, implement, and use classes on their own. They'll be challenged to reason about which data belongs in which class.

Name Concepts Status
Bitcoin arraylists, classes, final, compareTo Polish needed
Making Change classes, casting, strings Student approved
Mode Histogram classes, strings Student approved
Restaurant systems if statements, for loops, printing, classes, program design Student approved
Message in a bottle classes, visibility, arraylists Polish needed

Understanding hierarchy and inheritence

Students will be able to design, implement, and use their own classes that make use of object-oriented programming principles and inheritance.

Name Concepts Status
Lunch Special classes, interface, constructors Student approved
Chattering Chatterbot classes, inheritance Polish needed

Using others' code

Students will be able to understand code that they didn't write, and they'll also be able to modify it to achieve their own ends.

Name Concepts Status
Polygons classes, inheritance, interface Student approved
Land mine MVC, messaging, objects Student approved
The Watchmaker classes, debugging, code composition Idea sketch
Interfacing with playing cards compareTo, classes, inheritance Idea sketch

Extending code

Students will be able to design, implement, and write code to a specification so that someone else can adopt what has been written to his or her ends.


Contribute, edit, and comment on exercise resources on our mailing list or in our Github repository

Join list Visit repository