Computer Science Labs

Introduction

Over many years of teaching AP Computer Science, I developed labs for classroom use. I believed there was and still is a need for student work that is more complete than simple snippets of code, yet not as comprehensive as a multi-week case study. The projects are meant to cover specific CS topics in a non-trivial way, using interesting data.

Data in the labs is as historically accurate as possible. With my students, I find the data sets lead to interesting discussions well beyond the data structure or algorithm required to process it. Again, labs of this type can be more interesting than short code snippets and more approachable than case studies. These labs are meant to supplement those other assignment formats.

I have retired from full-time teaching and will not be enhancing or adding to the lab set, nor will I be upgrading the solutions for newest versions of Java or subset changes. Solution sets are no longer available from the author or from Asylum Computer Services LLC.

Lab Listings

The Java Labs are presented in a format suitable for printing and distribution to students following the lab handout link. Permission is granted to reproduce in any form or to post electronically the student version of the lab assignment.

Lab Title Description
1060 Three Little Fibs
lab handout
Use an interface and three classes that implement that interface to compute Fibonacci numbers. Each implementation uses a different technique: iteration, recursion, or a formula using the Golden Ratio to calculate Fibonacci numbers directly.
CS topics: interfaces, recursion, math library routines
1070 e
lab handout
A simple assignment in taking an algorithm and generating an object to calculate a value for the irrational number, e.
CS topics: ...
1080 pi
lab handout
Here's a lab that students all over the universe are doing, though not necessarily in Java. At least their algorithm is the same, as well as the answer: pi.
CS topics: ...
1120 Centalyzer
lab handout
A coin dealer needs you to write a program to determine how many coins dated before 1982 are in a sealed bag of 1000 cents. It's not magic, it's mathematics and a for loop.
CS topics: ...
1280 Slot machine
lab handout
Create a class that models the behavior of a slot machine. This lab gives good practice with compound conditionals to check winning combinations. The reels may be stored in an ArrayList. The lab can also be implemented with a HashSet created in the constructor storing the 39 possible winning combinations.
CS topics: conditionals, ArrayList, HashSet
1340 Spelling Rules
lab handout
Use string operations to check two common spelling rules: "i before e except after c" and that the letter 'q' is always followed by the letter 'u'. Of course, there are always exceptions.
CS topics: ...
1370 Old MacDonald
lab handout
Learn about inheritance and polymorphism by defining an Animal interface and then using that interface to create a cow, chicken and pig. Create a class that extends Cow to allow the cows to have names.
CS topics: inheritance, polymorphism
1380 Cards
lab handout
Follow a sequence of steps to define and implement a Card object and then a Deck (of 52 cards). Create another object, a Hand of cards, implement the deal and write code to use the classes to create poker hands, properly sorted.
CS topics: ArrayList, Comparable interface, insertion sort
1390 Fish Street Cemetery
lab handout
Find the average of life of people from Little Carter Lane who were buried at St. Mary Magdalene Cemetery, Old Fish Street, City of London from 1813 to 1853. Develop a Tombstone class to record information about each resident and a Cemetery class to hold all the pertinent information from the Tombstones.
CS topics: ...
1400 Tasmania, 1832
lab handout
In 1832, two hundred women sailed from England to a new home in Tasmania. Most were young and most were from penitentiaries, reform schools or asylums. Explore the data set to learn more.
CS topics: 1D int array, exceptions.
1410 Flesch Readability
lab handout
Write a program that computes the Flesch Readability Score for a document. The Flesch Readability Score measures the average sentence length in words and the average word length in syllables. Put these two numbers into a formula and get a number that shows you the difficulty of a piece of writing.
CS topics: ...
1420 Crickets
lab handout
While visiting South Carolina, I noticed a relationship between cricket chirps per minute and air temperature. Model an environment and crickets in that environment, with changing air temperatures. Extend a normal Carolina cricket to a Clemson cricket that chirps a bit slower.
CS topics: simple inheritance.
1430 Blackjack
lab handout
Use a group of six classes, including an abstract base class, to model the game of Blackjack. This lab is a logical extension of Lab 1380-cards.
CS topics: ...
1440 Royal Navy
lab handout
Create a nested linked list using officers' and ships' information from the British Royal Navy archives. Each ship in the primary linked list is populated with the correct crew using a second linked list. The resulting data structure is a linked list of ships, with each node containing a linked list of officers assigned to that ship in 1894.
CS topics: linked lists
1460 Shelby County Marriages
lab handout
Create a text-based or graphical solution to the question: "In which month did the most marriages occur in Shelby County, Kentucky from 1792-1800?" You will be surprised at the answer. This project introduces the Model-View-Controller design pattern, requiring students to implement only one significant method.
CS topics: ...
1480 Wonderland
lab handout
There once was a little girl named Rhonda. She liked to read books, but they were always about someone she didn't know: children named Alice or Cinderella. So Rhonda hired you to write a program using Java String methods that would change the name in the books (e-texts, of course) to her name.
CS topics: ...
1510 Paper Folds
lab handout
Ever fold a piece of paper several times, unfold it, and wonder how the pattern of folds was generated? Since you fold it over and over, it should be no surprise to see the solution is elegantly recursive.
CS topics: recursion.
1520 Cookie Monster
lab handout
This lab is based on the Cookie Monster activity from Litvin's excellent Java Methods AB, Data Structures book. This is a stack-based project with backtracking. A graphical shell (using a MVC) provides visual results.
CS topics: ...
1540 Maze
lab handout
Solve a randomly generated maze using the Stack data structure. Go everywhere until you find the exit. Always go left if you can, otherwise go straight, otherwise go right. If you can't go anywhere, back up until you can go somewhere using stack of previous locations. When you find the exit, the stack has the path through the maze.
CS topics: stack operations.
1570 Word Ladder
lab handout
This project attempts to find a word ladder between two user-selected
words such that any single step changes only one letter. Nested queues are the natural data structures
for this project, and the words can be stored in an ArrayList or TreeSet.
CS topics: ...
1610 Lightbulbs
lab handout
Use an ArrayList and an iterator to model a long hallway filled with light bulbs. Students pull chains as
they walk away, down the hall. When they are all gone, what do pattern do you see in the light bulbs remaining on?
CS topics: ...
1620 Ackermann
lab handout
Mathematical recursion using the harmless-looking Ackermann function. Be careful: the function grows very quickly. Be careful not to try to calculate an Ackermann number that you think might be just a little bit bigger. It might be a lot bigger. For example, A(4,1) is a five digit number. A(4,2) is a 19,729 digit number that is larger than the number of particles in the known universe.
CS topics: recursion (non-graphical)
1640 Tendron
lab handout
Use recursion to generate a graphic image. Your code will draw a "plant" recursively, modifying the structure as the elements get smaller, going through smaller branches and finally to leaves. Every time the tendron program runs, it generates a new and different plant since growth occurs randomly. Color is used to enhance the lifelike appearance.
CS topics: recursion (graphical).
1660 Forest Fire
lab handout
Will Blackhawk, Colorado burn? Light a simulated fire in the high mountain forest and, using recursion, determine if the first has a path to the town. This project uses the MVC pattern to display the path of the fire.
CS topics: ...
1750 Fish Tree
lab handout
Sort the names of those buried at St Mary Magdalene, Old Fish Street, City of London during the period 5/Jan/1813 to 10/July/1853 by their burial date. Use a TreeSet and a StringComparator class to maintain a sorted list. Use an iterator to display the burials, earliest date first.
CS topics: Tree Set, Comparable
1760 Morse Code
lab handout
Develop two classes that work with Morse Code: an encoder and a decoder. This project uses a TreeMap to store the sequence of dots and dashes that lead to encoding the message. A more challenging user-created tree using TreeNode objects is used for decoding.
CS topics: Tree Map
1770 Gray Code
lab handout
A computer gray code is a sequence in which only one bit position changes as the level changes by one step. These codes are used to convert real-world data to digital form. Use a HashMap or TreeMap to analyze data from the surface of Venus.
CS topics: ...
1790 Craps
lab handout
Create two classes: a Dice class and a Craps class. Use the Dice class to instantiate two Dice objects
to play the game of Craps. Use public and private methods as specified and Math.random to sequence
the play.
CS topics: ...
1810 Tropical Fruits
lab handout
Tropical fruits have been found to be high in potassium. Use a base class Linked List to extend an ordered linked list to store information about 22 tropical fruits.
CS topics: ordered linked list insertion, deletion.
1880 Up-Down
lab handout
Calculate how many possible sequences there are of n numbers such that each successive number
in the sequence alternates as being higher than, then lower than, the previous number.
CS topics: specifically designed for java.util.LinkedList using the underlying doubly linked list methods.
1890 U-D Sequences
lab handout
Calculate the actual sequences of n numbers such that each successive number in the sequence alternates as being higher than, then lower than, the previous number.
CS topics: ListQueue
1920 Keno
lab handout
Keno is a popular game, often played in restaurants while enjoying a meal away from the casino floor. But the winning pay tables are different depending on the casino. How many "picks" are best, and which casino has the best payout? Use actual data from Bally's, the Bellagio and the Casa Blanca casino in Las Vegas to find out.
CS topics: ...
1980 Emigrant Passengers
lab handout
On September 10, 1852, a small ship named the "Emigrant" left Sunderland in the Northeast of England bound for Melbourne, Australia. What sorts of people were needed to settle in their new country? Use a HashSet to explore the professions listed on the passenger list.
CS topics: ...
1990 Day in History
lab handout
Who else shares your birthday? Enters a month and date to search an ArrayList storing information
about events that happened in the month selected, then find events associated with the
specified day. A Hash Map allows one of several languages to be used to specify the month of interest.
CS topics: ...
2010 Superstition
lab handout
Which day of the week is the thirteenth of the month most likely to fall upon? Once you have determined how often the calendar repeats itself, use a GregorianCalendar object to cycle through all the days, counting how many Mondays, Tuesdays, &c. fall on the 13th of each month. Use a Hash Map to keep the tally.
CS topics: ...
2110 Hailstone Sequence
lab handout
Write a program to calculate the path of a mathematical "hailstone" starting at a given altitude. This project uses a simple form of the Model-View-Controller design pattern that can be adapted easily to other projects.
CS topics: ...
2280 Conway's Life
lab handout
This is an implementation of a cellular automata on a 2D grid. Once the original organisms are in place, simple rules determine what will happen in future generations. This project provides an animation framework for the student code. Several interesting initial populations are provided.
CS topics: 2D array of objects.
3020 Genetic Algorithms
lab handout
Use computational power to solve problems where the exact sequence of steps is not known in advance. Develop a small group of possible solutions, try them out, see which ones worked best, then generate new possibilities based on the best characteristics of the first generation. New, better solutions replace old ones, with random mutations and roulette selection, until a solution is found.
CS topics: artificial intelligence.

"AP" is a registered trademark of the College Board, which was not involved in the production of this web site.


Copyright © 1998-2017 by Asylum Computer Services LLC. Permission granted to reproduce for face-to-face teaching purposes. These labs are dedicated to Erin Dude.