# teaching machines

## CS 145 Lecture 21 – 2-D arrays, Image

### Code

#### Birthday2.java

package preexam2;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Birthday2 {

public static void main(String[] args) throws FileNotFoundException {

File file = new File("/home/user/bdays.csv");
Scanner in = new Scanner(file);

int[][] counters = new int[12][31];

while (in.hasNextInt()) {
int month = in.nextInt();
int day = in.nextInt();

++counters[month - 1][day - 1];
}

in.close();

for (int m = 0; m < counters.length; ++m) {
for (int d = 0; d < counters[m].length; ++d) {
if (counters[m][d] > 1) {
System.out.println("we've a repeat at " + (m + 1) + "/" + (d + 1) + "!");
}
}
}

//    for (int i = 0; i < counters.length; ++i) {
//      if (counters[i] > 1) {
//        System.out.println("we've a repeat at " + i + "!");
//        System.out.println("That is " + indexToMonthDay(i));
//      }
//    }

}
}

#### Artiste.java

package prefinal;

import java.io.FileNotFoundException;

public class Artiste {
public static void main(String[] args) throws FileNotFoundException {
Image image = new Image(480, 320);

image.noise();

image.writeToPGM("/home/user/blarb.pgm");
}
}