teaching machines

CS 148: Lab 1 – Madeup and Project Euler

Welcome to the first lab of CS 148!

Lab is a time intended for you to work on programming exercises in a low-stakes environment and with lots of help at your disposal. Read each of these out loud with your lab partner and check them off to acknowledge your understanding:

  • You complete a few checkpoints, which consist of short programming exercises.
  • Questions are always fair game. Your instructor and teaching assistant are here to help.
  • You work with a partner of your choosing, but this must be a different person each week. Talking through technical matters with other human beings is a key part of lab.
  • Groups of three are not allowed except by permission from the instructor.
  • You work at one computer only.
  • One person types for the first exercise. The other for the second checkpoint. And so on.
  • You must show your work to either your instructor or your teaching assistant to receive credit.
  • Both you and your partner must be present during checkoff time to receive credit.
  • Checkpoints are only checked during lab, not during office hours or over email.
  • If you don’t finish your checkpoints during a lab meeting, you can complete your work before next lab and get checked off during the first 10 minutes of the subsequent lab. No credit is granted if the work is not already complete before lab starts.

Many of these rules were crafted out of failures from earlier offerings of this course. These are designed to maximize the number of passing grades at the end of the semester.

Checkpoint 1

Recall the Madeup models that we programmed together on the first day of class. For instance, here’s the polygon program that we wrote:

This program demonstrates two foundational ideas in computer science:

  • variables, which give symbolic names for to the “actors” in our computation and which also allow us to tweak values in just one spot in our code
  • loops, which make mind-numbing repetition more mind-delighting

For your first checkpoint, you will apply these ideas to generate two other models.

Model A

Person A types. Visit Madeup.

Your first task is to create a chain link:

Model B

Person B types. Visit Madeup in a new tab.

Your second task is to create this funny symbol, which is used in the United Kingdom to mark a mechanic’s shop that can certify your vehicle:

Notice the rounded corners. These were automatically added by appending a named parameter to the dowel command:

dowel maxBend:1

So, use only a single yaw command to make each sharp bend, and then let the dowel command smooth it out.

When you have completed your two models, invite your instructor or teaching assistant over to offer feedback and make note of your accomplishment in the gradebook. If your instructor and TA are working with others at the moment, and you are confident that you’ve satisfactorily completed this checkpoint, please move on to the next checkpoint and catch them when they become available.

Checkpoint 2

We now leave Madeup and switch to a language that we will use most of this semester: Java.

In this course, we ask you to use the Eclipse develop environment to write Java code. Eclipse is one of many possible tools we could use to write Java. Netbeans and IntelliJ IDEA are also quite popular. There is no single best tool. We choose Eclipse because it has a very accommodating license and is widely used in industry.

Open Eclipse and follow these steps:

  • Choose a workspace, the place where all your code is stored. Enter H:\workspace. (The H: drive is your university drive, which is accessible all over campus and even from home. Do not put anything on the C: drive, which gets wiped frequently by LTS, our system administrators. You are free to place your workspace on a removable drive or simply use Eclipse on your personal machine, but you are responsible for properly managing and backing up your files. We cannot support your personal hardware.)
  • Create a new Java project in your workspace and name it labs148.
  • Right-click on the src directory and create a package named lab01.
  • Right-click on lab01 and create a new class named Countdown. Give it the following code:
    package lab01;
    public class Countdown {
      public static void main(String[] args) {
        for (int i = 10; i >= 0; --i) {
  • Run Countdown by clicking the green play button in the Eclipse toolbar. Confirm that you see output in the console.
  • Close Eclipse.
  • Open Eclipse again and make sure you it loads the workspace you created a moment ago. Do you see your project and package? Does the code in Countdown still run?

Now that we’ve got a place to store our code, let’s write some!

Problem A

Person A types. Visit Project Euler and register to create an account.

Pick one of the problems. Work out an algorithm on paper or markerboard in pseudocode. Then create a new class in lab01 named ProblemA. Translate your pseudocode to Java. Submit your answer to Project Euler. Fix your code until you have solved the problem.

Problem B

Person B types.

Pick a second problem, and solve it with the same process. Write your code in class ProblemB.

Once your solutions are working, show your work to your instructor or teaching assistant. Then log out and go do something amazing.


Leave a Reply

Your email address will not be published. Required fields are marked *