SeatingChart free response problem from the 2014 AP Computer Science A Exam.

SeatingChart is #3 from the from the 2014 AP Computer Science A Free Response problems.

http://media.collegeboard.com/digitalServices/pdf/ap/ap14_frq_computer_science_a.pdf

## Part (a) – SeatingChart constructor

public SeatingChart(List<Student> studentList, int rows, int cols) { seats = new Student[rows][cols]; int sIndex = 0; for(int c = 0; c < seats[0].length; c++) { for(int r = 0; r < seats.length; r++) { if(sIndex < studentList.size()) { seats[r][c] = studentList.get(sIndex); sIndex++; } } } }

## Part (b) – removeAbsentStudents method

public int removeAbsentStudents(int allowedAbsences) { int removed = 0; for(int r = 0; r < seats.length; r++) { for(int c = 0; c < seats[0].length; c++) { if(seats[r][c] != null && seats[r][c].getAbsenceCount() > allowedAbsences) { seats[r][c] = null; removed++; } } } return removed; }

Thank you so much, I’ve been struggling more than words could describe in my AP Comp Sci class and I think I’ll pass solely because of this glorious website. You are a legend my good sir.

Thanks for making this!