teaching machines

CS 145 Lab 8 – Spinner

Welcome to lab 8! If you have checkpoints from the last lab to show your instructor or TA, do so immediately. No credit will be given if you have not already completed the work, nor will credit be given after the first 10 minutes of this lab. You must work with a partner that you […]

CS 145 Lecture 22 – Images

Dear students, We start today by revisiting memory tracing, but this time in programs with loops. Here we go! Memory Tracing #1 public static String trace1(char c, int n) { String s = ""; for (int i = 0; i < n; ++i) { s += c; } return s; } public static void main(String[] […]

CS 145 Lecture 21 – Loops Cont’d

Dear students, Let’s start with a little Program This: Write a method indexOf that accepts a String and a char as parameters. Without using the builtin String.indexOf method, it returns the index at which the given character resides in the String. If no such character can be found, return -1. Then, let’s seem some more […]

CS 145 Lab 7 – Loops

Welcome to lab 7! If you have checkpoints from the last lab to show your instructor or TA, do so immediately. No credit will be given if you have not already completed the work, nor will credit be given after the first 10 minutes of this lab. You must work with a partner that you […]

CS 145 Lecture 20 – For

Dear students, Hey. Check out this while loop: int i = 0; while (i < 5) { System.out.println(i); ++i; } Let’s abstract this out a bit into its four parts and pieces: init while (condition) { body; update; } Loops are powerful, but any time you put a motor in something, it gets away from […]

CS 145 Lecture 19 – While

Dear students, Let’s start by analyzing this piece of code: public static boolean isIsosceles(double sideA, double sideB, double sideC) { if (sideA == sideB) { if (sideB == sideC) { return true; } else { return false; } } else { return false; } } Sniff it. Kick it. Pounce on it. Does it hold […]

CS 145 Lecture 18 – If Ladders

Dear students, Let’s start today by writing a little game modeled after an exercise that my kids do at school. It’s called Math Mountain. A number appears at the peak, and another small number appears at mountain’s left foot. The left and right foot are to sum up to the peak. The student must supply […]

CS 145 Lab 6 – Conditionals

Welcome to lab 6! If you have checkpoints from the last to show your instructor or TA, do so immediately. No credit will be given if you have not already completed the work, nor will credit be given after the first 10 minutes of this lab. You must work with a partner that you have […]

CS 145 Lecture 17 – Diversions and Bifurcations

Dear students, We’ve seen the computer as a calculator, crunching numbers. We’ve seen the computer as a chef, calling upon recipes of code. We’ve seen the computer as a philosopher, considering truths about our data. Now it’s time to let those truths drive our computer’s actions. We will see the computer as a pilot, navigating […]

CS 145 Midterm 1

See the PDF.

1 2 3 4 5 7