CS 18000 — Problem Solving and Object-Oriented Programming (Fall 2026)

Syllabus

Git and Version Control

October 14, 2026

A Little Beyond CS 180: Git and Version Control

Imagine you are working on a programming project for several weeks.

On Monday, your program works.

On Tuesday, you change 40 lines and add a feature.

On Wednesday, you realize that Tuesday’s change broke something important.

What do you do?

One possible strategy is to save lots of copies:

project/
project-old/
project-final/
project-final2/
project-final-actually-working/
project-final-please-do-not-break/

This works for a little while, but it creates several problems:

Which copy is the newest?
Which copy actually works?
What changed between two copies?
Why was a particular line changed?
What if two people changed different things?

Version control is a system for answering those questions.

Git is the most widely used version-control system for software.

—

Why Keep History?

Suppose this program works:

int total = price * quantity;

and then somebody changes it to:

int total = price + quantity;

A week later, the program is wrong.

If all we know is the current file, we see the bug, but we do not know:

When did this change happen?
Who changed it?
What was the old version?
Why did they change it?
What other changes happened at the same time?

Git keeps a history of meaningful versions of the project.

A saved point in that history is called a commit.

You can think of a commit as saying:

> “The project looked like this at this moment, and here is why I changed it.”

—

Why Not Store a Complete New Copy Every Time?

The simplest version-control system imaginable could copy the entire project every time anything changes.

version 1 -> entire project
version 2 -> another entire project
version 3 -> another entire project
version 4 -> another entire project

But suppose a project has 10,000 files and you change one line in one file.

Copying everything again would repeat an enormous amount of unchanged information.

We want two things at once:

1. Be able to reconstruct the entire project at an old version.

2. Avoid treating every unchanged file as brand-new information.

Git conceptually treats each commit as a snapshot of the project, but unchanged content can be reused rather than duplicated. Git can then compare two snapshots and show the difference between them.

For example:

- int total = price + quantity;
+ int total = price * quantity;

That difference is called a diff.

A diff is useful because humans usually care about:

> What changed?

rather than:

> Show me two enormous files and make me find the difference myself.

—

Why Do We Need Commits? Why Not Save Every Keystroke?

Your editor already saves files.

Git is trying to solve a different problem.

During ten minutes of programming, you might temporarily have code like:

int x = ;

or half-finished changes that do not compile.

Most of those intermediate states are not useful landmarks.

A commit lets you decide:

> “This is a meaningful state of the project that I may want to return to later.”

Good commits usually represent one coherent idea:

Add input validation
Fix score calculation
Rename confusing variables
Add tests for empty input

This is why commit messages matter. A history like:

fix
stuff
more stuff
thing

tells us almost nothing.

A history like:

Reject negative quantities
Fix off-by-one error in search
Add tests for duplicate names

explains the evolution of the program.

—

The Basic Workflow

Suppose you edit two files:

Main.java
GradeCalculator.java

First, Git can tell you what has changed:

git status

To inspect the changes:

git diff

Then you choose which changes should be part of the next commit:

git add GradeCalculator.java

Finally:

git commit -m "Fix grade calculation"

Conceptually:

working directory
      |
      | git add
      v
changes selected for next commit
      |
      | git commit
      v
project history

—

Why Is There a Staging Area?

Why not just have git commit save every changed file?

Because you might be doing two unrelated things at once.

Suppose you changed:

GradeCalculator.java   -> fixed a bug
Main.java              -> started an unfinished new feature

You want the bug fix to be a clean commit, but the new feature is not ready.

The staging area lets you say:

> “Put these changes in my next commit, but leave the others for later.”

This makes history easier to understand and makes individual changes easier to undo.

—

Why Have Branches?

Suppose your current program works.

You want to try a risky idea:

Rewrite the entire scoring system.

If you work directly on the only copy, the program may be broken for several days.

Instead, make another line of development:

                new-scoring
               /    o---o---o
              /
main     o---o---o---o

This is a branch.

A branch lets us explore a sequence of changes without immediately changing the main version.

git switch -c new-scoring

You can now make commits on that branch.

Meanwhile, main can remain stable.

Branches are useful because software development often contains uncertainty:

Will this idea work?
Will this take one hour or three days?
Will somebody else need to fix an unrelated bug meanwhile?

A branch isolates one line of work from another.

—

Why Not Just Make Another Folder Instead of a Branch?

You could make:

project-main/
project-new-scoring/

But then the histories are disconnected copies.

If somebody fixes a bug in the main project, how do you cleanly combine that fix with your new scoring system?

Git branches remember that both lines of work came from the same earlier commit.

            A---B---C
           /
X---Y-----Z
           \
            D---E

Git knows that both branches share history through Z.

That makes combining them much more systematic.

—

Why Do We Need Merging?

Eventually the experiment works.

Now we want both lines of history to become one project again.

That is a merge.

Suppose one branch changed Calculator.java and another branch changed Menu.java.

branch A: changed Calculator.java
branch B: changed Menu.java

Git can usually combine these automatically because the changes do not interfere.

Conceptually:

            change Calculator
           /                \
old version                  combined version
           \                /
            change Menu

—

Why Do Merge Conflicts Exist?

Git can combine changes only when it can determine what the combined result should mean.

Suppose the original code is:

int score = 10;

Alice changes it to:

int score = 20;

while Bob changes the same line to:

int score = 100;

What should the merged program contain?

int score = 20;

or:

int score = 100;

Git cannot answer that question because it is a question about what the program is supposed to do.

So Git stops and reports a merge conflict.

A conflict does not mean Git failed.

It means:

> “Two histories made incompatible edits here, and a human needs to decide the intended result.”

Git might show something like:

<<<<<<< current branch
int score = 20;
=======
int score = 100;
>>>>>>> other branch

You edit the file into the version you actually want, remove the markers, and then commit the resolution.

—

Why Do We Need GitHub If We Already Have Git?

Git works on your computer.

You can use Git completely without GitHub.

GitHub provides a shared place to store Git repositories.

This gives us several useful things:

backup
collaboration
code review
issue tracking
automation
a shared source of truth

Your computer might have:

local repository

while GitHub has:

remote repository

To send your commits to the remote:

git push

To retrieve new commits:

git pull

—

Why Can git pull Cause a Conflict?

Suppose you and a classmate both start from the same version.

You change line 10.

Your classmate also changes line 10 and pushes first.

Your histories now disagree:

           your change
          /
old -----+
          \
           classmate's change

Pulling means Git must combine those histories.

If both changed the same meaningfully overlapping code, Git cannot know which intention should win.

So again, a merge conflict is unavoidable unless some human or higher-level rule decides what the correct program should be.

—

Why .gitignore?

Not every file in a project belongs in version control.

Java compilation may create files such as:

Main.class

Your editor might create temporary files.

A program might generate logs or large output files.

If those files can be recreated automatically, tracking them often adds noise.

A .gitignore file says:

> “These files may exist on my computer, but they are not part of the source history I want Git to track.”

For example:

*.class
build/
.idea/

—

Why Version Control Matters Beyond Programming

Git is not fundamentally about Java.

It is about managing change in a complicated artifact.

The same questions appear whenever people build something over time:

What changed?
Why did it change?
Can I undo it?
Can two people work independently?
Can their work be combined?
Who made this decision?

Git gives precise answers to those questions for files.

The Main Mental Model

edit       -> change the working copy

git add    -> choose what belongs in the next checkpoint

commit     -> create a meaningful checkpoint in history

branch     -> create an independent line of work

merge      -> combine lines of work

conflict   -> Git cannot determine the intended combination

push       -> send local commits to a remote repository

pull       -> bring remote commits into your local repository

The important idea is not memorizing commands.

It is understanding the problem each command exists to solve.

Lab 6

October 11, 2026

Guest Lecture on Karatsuba’s Algorithm for Multiplication by Corbet Elkins

Lab 6

October 09, 2026

Guest Lecture on Prophet Inequalities by Abhiram Manohara

Lab 5

September 30, 2026

A Little Beyond CS 180: Dynamic Programming

Suppose we have coins worth:

1, 3, and 4

and want to make:

6

using as few coins as possible.

One natural idea is:

> Always take the largest coin that still fits.

That gives:

6 = 4 + 1 + 1

which uses 3 coins.

But we can do better:

6 = 3 + 3

which uses only 2 coins.

So the obvious greedy choice does not always work.

—

Solve Smaller Problems First

Instead of trying to solve 6 all at once, suppose we already knew the best answer for every smaller amount.

amount:  0  1  2  3  4  5  6
best:    0  1  2  1  1  2  ?

What could the last coin in a solution for 6 be?

It could be a 1, a 3, or a 4.

If the last coin is 1:

best way to make 5 + one more coin
= 2 + 1
= 3 coins

If the last coin is 3:

best way to make 3 + one more coin
= 1 + 1
= 2 coins

If the last coin is 4:

best way to make 2 + one more coin
= 2 + 1
= 3 coins

Therefore:

best[6] = 2

The important idea is:

> If I already know the answers to the smaller problems, I can use them to build the answer to the larger problem.

—

Remember the Answers

We can store the answer for each amount in an array.

int[] best = new int[7];

Think of it as seven labeled boxes:

index:   0  1  2  3  4  5  6
         +--+--+--+--+--+--+--+
best:    |  |  |  |  |  |  |  |
         +--+--+--+--+--+--+--+

best[x] means:

> The fewest coins we have found for making amount x.

We know one answer immediately:

best[0] = 0;

It takes zero coins to make zero.

Now fill the table from left to right.

void main() {
  int[] best = new int[7];

  best[0] = 0;

  for (int amount = 1; amount <= 6; amount++) {
    best[amount] = 1000; // Start with an obviously bad answer.

    if (amount >= 1) {
      best[amount] =
          Math.min(best[amount], 1 + best[amount - 1]);
    }

    if (amount >= 3) {
      best[amount] =
          Math.min(best[amount], 1 + best[amount - 3]);
    }

    if (amount >= 4) {
      best[amount] =
          Math.min(best[amount], 1 + best[amount - 4]);
    }
  }

  IO.println(best[6]); // 2
}

As the loop runs, the array becomes:

best[0] = 0
best[1] = 1
best[2] = 2
best[3] = 1
best[4] = 1
best[5] = 2
best[6] = 2

We never need to solve the same smaller problem again. We just look up the answer we already stored.

—

This Is Dynamic Programming

Dynamic programming is a general technique:

1. Break a problem into smaller problems.

2. Solve the smaller problems.

3. Store their answers.

4. Reuse those answers to solve larger problems.

A useful set of questions to ask is:

> What smaller problems would help me solve this problem?

> Will I need the answers to those smaller problems again?

> Can I save those answers instead of recomputing them?

For coin change, our smaller problem is:

"What is the fewest number of coins needed to make x?"

Once we know that answer for every smaller x, we can build the next answer.

—

The Same Idea in a Different Problem

Suppose each square in a grid has a cost.

You start in the upper-left corner and can only move:

right
or
down

Find the cheapest path to the bottom-right.

1   4   2   1
3   1   5   2
2   2   1   3

To reach any square, your previous square must have been either:

directly above
or
directly to the left

So if we already know the cheapest way to reach those two squares:

cheapest way to reach this square
    =
cost of this square
    +
min(
    cheapest way from above,
    cheapest way from the left
)

Again, the larger problem is built from answers to smaller problems.

The code would look different from coin change, but the idea is the same.

—

The Bigger Idea

Dynamic programming is not one particular algorithm.

It is a way of recognizing structure in a problem.

brute force:
    solve the same subproblems again and again

dynamic programming:
    solve each useful subproblem once
    remember the answer
    reuse it later

A lot of algorithm design comes down to choosing the right thing to remember.

For coin change, we remembered:

best answer for every amount

For the grid problem, we remember:

best answer for every location

Once you decide what the smaller problems should be, the rest of the algorithm often becomes much easier to see.

Lab 4

September 22, 2026

A Little Beyond CS 180: Fair Division

Suppose several people want to divide one cake.

If everyone valued every part of the cake equally, we could just cut equal-sized pieces. But people may care about different parts:

Alice:  really likes the chocolate side
Bob:    really likes the strawberry side

So “equal size” and “equal value” are not the same thing.

In fair division, each person gets to decide how valuable each part is to them.

What Does Fair Mean?

One simple goal is proportionality.

With n people, an allocation is proportional if every person receives a piece that they value at least:

1 / n

of the whole cake.

The values do not have to agree.

Alice might think her piece is worth 60% of the cake.
Bob might think Alice's piece is worth only 10%.

That is fine. Fairness is measured using each person’s own values.

—

Two People: Cut and Choose

Suppose Alice and Bob want to divide a cake.

  1. Alice cuts the cake into two pieces that she values equally.
  2. Bob chooses whichever piece he prefers.
  3. Alice gets the piece that remains.
               Alice cuts
                   |
                   v

+------------------+------------------+
|     worth 1/2    |     worth 1/2    |   to Alice
+------------------+------------------+

                      Bob chooses first

Why is this fair?

For Alice:

Alice made both pieces worth exactly half to her.

Bob can take either one, but Alice still gets:

1 / 2

of the value of the cake according to Alice.

For Bob:

Bob chooses his favorite of the two pieces.

At least one of two pieces must be worth at least half of the cake to him.

So Bob also gets at least:

1 / 2

according to Bob.

Therefore cut-and-choose is proportional.

In fact, for two people it gives something stronger: neither person prefers the other person’s piece, so it is also envy-free.

—

What About More People?

Suppose there are four people:

Alice
Bob
Charlie
Dana

We want everyone to receive at least 1/4 of the cake by their own valuation.

We can use the same idea as binary search:

> Divide the problem into two smaller problems, solve each one, and recurse.

Step 1: Everyone Finds Their Half

Ask every person:

> “Where would you cut so that the cake to the left is worth exactly half to you?”

They might give very different answers:

cake
0%                                              100%
|------------------------------------------------|
       A          B                 C       D
       |          |                 |       |
      20%        35%               65%     80%

Sort the marks from left to right.

Cut at the second mark:

+----------------+-------------------------------+
     A, B                       C, D

Put the two people with the leftmost marks in the left group.

Put the other two people in the right group.

Why Can We Safely Do This?

Alice and Bob placed their halfway marks at or before the cut.

So each of them thinks the entire left piece is worth at least half of the original cake.

Charlie and Dana placed their halfway marks at or after the cut.

So each of them thinks the right piece is worth at least half of the original cake.

We have reduced:

4 people + 1 cake

into:

2 people + a piece worth >= 1/2 to each of them

and

2 people + a piece worth >= 1/2 to each of them

Now run cut-and-choose separately inside each group.

Each person gets at least half of a piece they valued at least half of the original cake:

1/2 * 1/2 = 1/4

So everyone gets at least one quarter of the value of the original cake.

—

The General Divide-and-Conquer Algorithm

Suppose a group contains k people and has some piece of cake C.

Split the people into groups of sizes:

a = floor(k / 2)
b = k - a

Ask every person to mark a point where the left part is worth:

a / k

of C to them.

Then:

1. Sort the marks.

2. Cut at the a-th mark.

3. Send the a people with the leftmost marks left.

4. Send the remaining b people right.

5. Repeat on each side.

Stop when a group contains only one person. That person gets the remaining piece.

In pseudocode:

divide(people, cake):

    if there is only one person:
        give them the cake
        return

    split the people into groups of sizes a and b

    everyone marks where the left side
    is worth a/k of the current cake

    sort the marks
    cut at the a-th mark

    divide(left group, left cake)
    divide(right group, right cake)

This is essentially the same divide-and-conquer idea that appears throughout algorithms.

—

Why Does It Work?

The important idea is an invariant: every time we recurse, the remaining cake is valuable enough for the number of people who still need to share it.

Suppose there are k people sharing a piece that each of them values at least:

k / n

of the original cake.

The left group has a people.

Because they made the leftmost marks, every person sent left values the left piece at least:

a / k

of the current piece.

Therefore they value it at least:

(a / k) * (k / n) = a / n

of the original cake.

Similarly, every person sent right values the right piece at least:

b / n

of the original cake.

So the same guarantee holds again in both smaller problems.

Eventually a group contains exactly one person.

At that point, that person’s remaining piece is worth at least:

1 / n

of the original cake.

Therefore the final allocation is proportional.

—

Why This Is a Theory CS Problem

There are two separate questions:

1. Can we design an algorithm that produces a fair allocation?

2. Can we prove that the algorithm always has the property we want?

The code or procedure can be simple. The interesting part is often the guarantee.

Here the guarantee is:

> No matter how differently the agents value the cake, every agent receives at least 1/n of the total value according to their own valuation.

There are many other possible notions of fairness.

Proportionality:
    Do I get at least my fair share?

Envy-freeness:
    Do I prefer my own piece to everyone else's?

Efficiency:
    Could we make someone better off without making
    somebody else worse off?

These goals do not always behave the same way, which is where fair division becomes much more interesting.

Lab 3

September 16, 2026

Loops: Two Questions

Once we have loops, there are two natural questions we can ask:

The first question leads to algorithms and complexity. The second leads to computability.

How Much Work Does a Loop Do?

for (int i = 0; i < n; i++) {
  // This runs about n times.
}
while (n > 1) {
  n = n / 2;
  // This runs about log_2(n) times.
}
for (int i = 0; i < n; i++) {
  for (int j = 0; j < n; j++) {
    // This runs about n^2 times.
  }
}

We often care less about the exact number of seconds a program takes and more about how the amount of work grows when the input gets bigger.

n       n        log_2(n)       n^2
10      10       ~3             100
100     100      ~7             10,000
1000    1000     ~10            1,000,000

This is the beginning of algorithm analysis.

A Strange Loop: The Collatz Conjecture

Consider a positive integer n. Repeatedly do the following:

void main() {
  long n = Long.parseLong(IO.readln("Enter a positive integer:\n"));

  while (n != 1) {
    IO.println(n);

    if (n % 2 == 0) {
      n = n / 2;
    } else {
      n = 3 * n + 1;
    }
  }

  IO.println(1);
}

For example, starting with 6:

6 -> 3 -> 10 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1

The natural question is:

> Does this loop terminate for every positive integer?

Nobody knows. This is the Collatz conjecture: no proof is known that every positive integer eventually reaches 1, and no counterexample is known either.

That gives us a much more general question:

> Given a program and its input, can another program always determine whether it will eventually stop?

The Halting Problem

Imagine Java had a magical function like this:

// Imaginary pseudocode -- Java does not actually have this function.
boolean halts(Program program, Input input);

It returns true if the program eventually stops and false if the program runs forever.

If such a function existed, we could build this strange program:

// Pseudocode
void strange(Program program) {
  if (halts(program, program)) {
    while (true) {
      // Loop forever.
    }
  } else {
    return;
  }
}

strange deliberately does the opposite of what halts predicts.

Now ask what happens when we run:

strange(strange);

There are only two possibilities:

Either answer contradicts itself. Therefore a perfect halts function cannot exist.

This is the Halting Problem: there is no algorithm that can correctly decide whether every possible program will halt on a given input.

The progression is:

comparisons
    -> which path do I take?
loops
    -> how many times do I take it?
algorithms
    -> how much work will this take?
computability
    -> will this computation finish at all?

Lab 2

September 12, 2026

Comparisons and Decisions

void main() {
  int x = 5;
  int y = 10;

  // Comparisons give us a boolean: true or false.
  IO.println(x < y);   // true
  IO.println(x > y);   // false
  IO.println(x == y);  // false
  IO.println(x != y);  // true
  IO.println(x <= y);  // true
  IO.println(x >= y);  // false

  x = 10;              // = means ASSIGN a value
  IO.println(x == y);  // == means COMPARE two values
}

Comparing Strings

void main() {
  String word = IO.readln("Enter a word:\n");

  // For Strings, use .equals() to compare their contents.
  IO.println(word.equals("Hello"));

  // Capitalization matters.
  IO.println(word.equals("hello"));
}

Comparing Doubles

void main() {
  double x = Double.parseDouble(IO.readln("Enter a number:\n"));

  IO.println(x > 3.0);
  IO.println(x < 3.0);

  // Doubles sometimes have tiny rounding errors.
  // Instead of checking x == 3.0, check whether they are very close.
  double delta = 0.0001;

  IO.println(Math.abs(x - 3.0) < delta);
}

Making Decisions

void main() {
  int age = Integer.parseInt(IO.readln("Enter your age:\n"));

  if (age < 13) {
    IO.println("Child");
  } else if (age < 18) {
    IO.println("Teenager");
  } else {
    IO.println("Adult");
  }
}

AND and OR

void main() {
  int age = 16;

  // && means AND: BOTH sides must be true.
  if (age >= 13 && age < 18) {
    IO.println("Teenager");
  }

  // || means OR: AT LEAST ONE side must be true.
  if (age < 13 || age >= 65) {
    IO.println("Discount");
  }
}

Switch

void main() {
  String grade = IO.readln("Enter your grade:\n");

  // switch is useful when comparing against several specific values.
  switch (grade) {
    case "A" -> IO.println("Excellent");
    case "B" -> IO.println("Good");
    case "C" -> IO.println("Okay");
    default -> IO.println("Unknown grade");
  }
}

Use if when testing conditions or ranges; switch is often cleaner when matching one value against several specific options.

—

A Little Beyond CS 180: == vs .equals()

Last week, we thought of a variable as a place where the computer stores something.

For an int, that simplified picture works well:

int x = 5;
x
+---+
| 5 |
+---+

Objects work a little differently.

String word = new String("Hello");

A useful mental model is:

word                     String object
+-----------+             +---------+
| reference | ----------> | "Hello" |
+-----------+             +---------+

The variable stores a reference to an object.

Now consider:

void main() {
  String a = new String("Hello");
  String b = new String("Hello");

  IO.println(a == b);      // false
  IO.println(a.equals(b)); // true
}

Conceptually:

a --------> +---------+
            | "Hello" |
            +---------+

b --------> +---------+
            | "Hello" |
            +---------+

The two objects contain the same text, but they are two different objects.

a == b

roughly asks:

> Do a and b refer to the same object?

while

a.equals(b)

asks:

> Do the objects have the same contents?

So .equals() is not just a strange Java rule. It asks a different question.

—

A Little Beyond CS 180: Binary Search

Comparisons can also be thought of as questions that give us information.

Suppose I pick a number from 1 to 100.

You could ask:

Is it 1?
Is it 2?
Is it 3?
...

In the worst case, that takes about 100 questions.

But instead, start in the middle:

Is the number <= 50?

Now half the possibilities disappear.

If I say no:

51 ... 100

Ask again:

Is the number <= 75?

Now half disappear again.

100 possibilities
        ↓
50
        ↓
25
        ↓
~12
        ↓
~6
        ↓
~3
        ↓
~2
        ↓
1

So we only need about 7 questions to find one number among 100.

This idea is called binary search.

Binary Search in Code

Suppose we have a sorted array:

int[] numbers = {2, 5, 8, 12, 17, 23, 31, 42, 55};

and want to find 23.

Start with the whole array:

2  5  8  12  17  23  31  42  55
            ^
          middle

17 < 23, so everything to the left of 17 can be ignored:

23  31  42  55

Look in the middle again:

23  31  42  55
    ^

31 > 23, so everything to the right can be ignored:

23

Found it.

A simplified implementation looks like:

void main() {
  int[] numbers = {2, 5, 8, 12, 17, 23, 31, 42, 55};

  int target = 23;

  int low = 0;
  int high = numbers.length - 1;

  while (low <= high) {
    int middle = (low + high) / 2;

    if (numbers[middle] == target) {
      IO.println("Found it!");
      break;
    } else if (numbers[middle] < target) {
      // The target must be to the RIGHT.
      low = middle + 1;
    } else {
      // The target must be to the LEFT.
      high = middle - 1;
    }
  }
}

You do not need to know the array or while syntax yet. The important idea is just what each comparison accomplishes:

if (numbers[middle] < target)

does not merely produce true or false.

It tells us:

> Half of the remaining possibilities cannot possibly be the answer.

That is why binary search is fast.

How Fast?

If we double the amount of data, binary search only needs roughly one more comparison.

Elements       Worst-case comparisons
10             ~4
100            ~7
1,000          ~10
1,000,000      ~20
1,000,000,000  ~30

So with only about 20 yes/no questions, we can distinguish between more than a million possibilities:

2^20 = 1,048,576

This is logarithmic in the size of the input

Lab 1

September 04, 2026

Reading and Storing Strings

void main() {
  String h; // Make enough space on my computer to store a string. From now on, when I refer to "h", I am referring to what is in that space.
  h = "Hello"; // Set the value at "h" to "Hello"
  String w = "World!";  // Make enough space on my computer to store a string. Put "w" at that space.


  IO.readln("Prompt\n"); // Print out "Prompt", add a newline (that's what "\n" means), and then read in input.
  IO.println("Prompt"); // Print out "Prompt", add a newline
  IO.readln(); // Read in input

  IO.println("Hi there"); //println automatically adds a newline after printing
  IO.print("Hi there\n"); //print does not
}

FavoriteThings.java

  String name = IO.readln("Enter your first name:\n");
  String food = IO.readln("Enter your favorite food:\n");
  String hobby = IO.readln("Enter your favorite hobby:\n");
  IO.println(name + "'s favorite food is " + food + " and " + name + " likes " + hobby + "!")

Reading and Storing Strings

void main() {

  String notnumber = IO.readln("Enter a number:\n"); // Let's say I want to read a number. If I try to use this as a number, I get big problems! On the computer, the value is represented differently. Java knows this, and won't compile the program.
  int number = Integer.parseInt(notnumber); // Thankfully, Java provides a function "Integer.parseInt" to help us out.

  // What would happen if the user passed on "abc" instead of a number?
  // The program would throw an exception (demo this)
}

AgeCalc.java

void main() {
  String ageString = IO.readln("Enter your age:\n");
  int age = Integer.parseInt(ageString);
  int birthage = 2026-age;
  int graduationage = age + 4;

  IO.println("You were born in " + birthage + ".\nYou will be " + graduationage + "when you graduate.");
}

Basic String Manipulation

void main() {
  String word = "Hello";

  IO.println(word.length()); // Number of characters in the String: 5

  // Strings are indexed starting at 0.
  // H e l l o
  // 0 1 2 3 4

  IO.println(word.charAt(0)); // Character at index 0: H
  IO.println(word.charAt(4)); // Character at index 4: o

  IO.println(word.indexOf('l')); // Index of the FIRST 'l': 2
  IO.println(word.indexOf('z')); // -1 means the character was not found

  IO.println(word.toUpperCase()); // HELLO
  IO.println(word.toLowerCase()); // hello

  // These methods return a new String. They don't change word.
  IO.println(word); // Hello

  word = word.toUpperCase(); // Store the returned String back into word
  IO.println(word); // HELLO
}

Substring

void main() {
  String word = "Hello";

  // H e l l o
  // 0 1 2 3 4

  IO.println(word.substring(1)); // "ello": start at index 1 and go to the end

  IO.println(word.substring(1, 4));
  // "ell"
  // Start at index 1, INCLUDING index 1.
  // Stop at index 4, NOT INCLUDING index 4.
}

IndexOutOfBoundsException

void main() {
  String word = "Hello";

  IO.println(word.length()); // 5

  // The indices are 0, 1, 2, 3, 4.
  // Even though the length is 5, there is no character at index 5.

  IO.println(word.charAt(4)); // Works: o
  IO.println(word.charAt(5)); // Throws an IndexOutOfBoundsException
}

StringMachine.java

void main() {
  String word = IO.readln("Enter a word:\n");

  IO.println(word.toUpperCase());
  IO.println(word.toLowerCase());

  int length = word.length();

  // The first character is always at index 0.
  char first = word.charAt(0);

  // Since indices start at 0, the last character is at length - 1.
  char last = word.charAt(length - 1);

  IO.println(length + " " + first + " " + last);

  // Start after the first character.
  // Stop before the last character.
  IO.println(word.substring(1, length - 1));
}

Common Errors

void main() {
  IO.println("Welcome to MyDebug!");

  String name = "Michael";

  IO.println("Enter your age:");

  int age = Integer.parseInt(IO.readln());

  String city = IO.readln("Enter your city:\n");

  city = city.toUpperCase();

  IO.println("Hello I am " + name);
  IO.println("I am " + age + " years old");
  IO.println("I am from " + city);

  IO.println("Program Complete!");
}
void main() {
  IO.println("Welcome to MyDebug!");

  String name = "Michael";

  IO.println("Enter your age:");

  int age = Integer.parseInt(IO.readln());

  String city = IO.readln("Enter your city:\n");

  city = city.toUpperCase();

  IO.println("Hello I am " + name);
  IO.println("I am " + age + " years old");
  IO.println("I am from " + city);

  IO.println("Program Complete!");
}

Debug Challenge 2

void main() {
  IO.println("Welcome to CS180!");

  IO.println("Enter your first name:");

  String name = IO.readln();

  IO.println("Hello " + name + "!");

  IO.println("Your name contains " + (name.length())
          + " characters.");

  IO.println("Your first initial is "
          + name.charAt(0) + ".");

  IO.println("Your name in uppercase is "
          + name.toUpperCase() + ".");

  IO.println("Program Complete.");
}

Welcome

August 23, 2026

Hello! Welcome to CS 180 (Problem Solving And Object-Oriented Programming). My name is Iniyan and I will be your TA. This course primarily discusses the basics of programming, inheritance, exception handling, and a few algorithms and their implementations.

As we go through this course, I will share resources and information on this page. If you would like to meet with me to discuss this class, your grades, etc., you can meet with me during lab/office hours.

Generally, I am most responsive via email, but feel free to follow up if I don’t respond in 1 business day. I will not give any solutions on email or during lab/office hours, but I will help guide you to the correct answer. I highly recommend attending lab/office hours if you have questions, since I can give answers right away. I may not respond as quickly to questions answered on this page, so please double-check before asking.

Lab attendance is worth 5% of your final grade, so you are incentivized to attend. I’ll start each lab with a brief recap of the topics used, and then the rest of the time will be for solving problems/asking questions.

There will be no final exam, but there will be four midterms in weeks 6, 9, 12, and 15 (Sep 28 - Oct 1, Oct 19 - 22, Nov 9 - 12, Nov 30 - Dec 3). Each midterm has one retake, and your grade will be the best of the two attempts. They are the same scope and difficulty, and will cover the same content. You should be given a syntax guide, since the point of the course is not memorization, but understanding.

I have two office hours times, Monday and Wednesday from 4:30pm-5:20pm.

You can subscribe to my announcements (which are not a replacement for the course announcements, just will reflect any notes/advice I take throughout, although I will try to repost here) via this RSS Feed.