Like many fellow AP Computer Science teachers, I like to hammer on concepts and then allow the students to program. Often, after learning a new concept, we work through an example as a class. For example, after learning about arrays, we go through an example of counting the total for each letter in the alphabet. After that, I like to assign programs which encompass multiple concepts. Here are the backbone programs I use throughout the course of a year…
ASCII Convert - This program really allows the students to grasp the idea of characters vs String. I have the students take the number 8 – 256 and print out the integer, double, base 2, base 16, and ASCII character. It creates an easy to read conversion table.
Base Number Conversion - This program only a user to convert between any two bases. Some prefer to wait until the students learn about Stacks; however, we go through with loops and conditionals to makes the proper conversions. Converting 562 Base 7 to Base 16, we would go to base 10 and then use division and the remainder to find the final conversion.
UPC Code - This is explained in a previous blog entry.
Roshambo - This is Rock, Paper, & Scissors. I love that fact that this is an easy way to utilize random numbers, conditionals, and a while loop. The students feel this program is “easy”; therefore, I make use of the simplicity of this program to describe larger programs. If the students understand that programming is basically like building blocks, then they are more likely to succeed.
Tic Tac Toe - I use this program throughout the year; however, not like you would think. I often say “If you can’t program this, then you can’t handle Tic Tac Toe.” I use this program to pressure the students, motivate the students, and assign it around Christmas time. This year, it was the Christmas Break project. Many teachers out there use this as a major project, but it really does show if the students understand program flow. I remember, when taking AP Computer Science A via C++, I was really confused until I figured out how to keep the game running. This was my lightbulb moment and allowed me to be successful from that point.
Gorilla - This is much like the original QBasic game which was called Gorilla. The object is to throw an object that hits a target. Specific details…
1. The target is 2 m wide on a 500m course. The students produce a random number from 2 to 499 which encompasses the entire course.
2. The gorilla throws the object with a user specified velocity and angle. So adjusting the angle and velocity changes how far the object will travel.
3. The distance the object travels is given by…
4. The program continues to tell the user how far away from the target they are until the target has been hit.
This program uses many code practices including user input, while loops, for loops, if-else structures, and math.
Galton Board - A Galton Board is much like the famous Price is Right game titled Plinko. You drop a ball at the very top and watch it until it lands in a specific location (I will call them containers). A great animation can be seen here. Depending on the number rows in the Galton Board, the number of containers is always rows + 1 because there is always the outside of the beginning and end post that create the need for an extra container.
Deal or No Deal - I have a copy of an episode where the contestant goes through the entire board. The students get to see the full set of rules and possibilities. This is a fun program for the students. Once again, program control flow is a HUGE DEAL.
Audioactive Sequence - Have the students create a program which continues this pattern…
Sigma Value of a Number - The Sigma Value of a number is the digit sum of the number. There are many patterns that occur during the process of going through many different well known sequences. For example, the Sigma Value of 1927362 is 3. Because 1+9+2+7+3+6+2 = 30 = 3 + 0 = 3.