2005 AP CSA FRQ 1: Hotel - Complete Solution

2005 AP CSA FRQ 1: Hotel

Topic: ArrayList & Object Management

Skills Tested: Array traversal, ArrayList operations, object creation, null checking

Curriculum Alignment: Unit 4 (Data Collections) (2025-2026 AP CSA)

Points: 9 | Time Estimate: ~22 minutes

Part (a)

Write the requestRoom method that assigns a guest to the first available room or adds them to the waitlist.

Try It First! Attempt to solve this part before viewing the solution. Use the concepts: Array traversal.

Solution

public Reservation requestRoom(String guestName)
{
    for (int i = 0; i < rooms.length; i++)
    {
        if (rooms[i] == null)
        {
            rooms[i] = new Reservation(guestName, i);
            return rooms[i];
        }
    }
    
    waitList.add(guestName);
    return null;
}

Part (b)

Write the cancelAndReassign method that cancels a reservation and assigns the room to the first person on the waitlist.

Solution

public Reservation cancelAndReassign(Reservation res)
{
    int index = res.getRoomNumber();
    
    if (waitList.size() > 0)
    {
        String guestName = (String) waitList.remove(0);
        rooms[index] = new Reservation(guestName, index);
    }
    else
    {
        rooms[index] = null;
    }
    
    return rooms[index];
}

Key Concepts

null represents an empty room in the array
ArrayList.remove(0) removes and returns the first element
Create new Reservation objects with constructor
Return null when no room is available

Common Mistakes to Avoid

Forgetting to check if waitList is empty before removing
Not setting rooms[index] to null when no one is waiting
Returning the wrong value (old vs new reservation)
Index errors when accessing the rooms array

Scoring Guidelines

Total Points: 9

Points are awarded for:

  • Correct loop structure and bounds
  • Proper method calls and return statements
  • Correct conditional logic
  • Handling edge cases appropriately

Partial credit is available for demonstrating understanding even with minor syntax errors.

Official College Board Resources

About the Author: Tanner Crow is a certified AP Computer Science teacher with 11+ years of experience helping students succeed on the AP CSA exam.

Last updated: January 2026

Get in Touch

Whether you're a student, parent, or teacher — I'd love to hear from you.

Just want free AP CS resources?

Enter your email below and check the subscribe box — no message needed. Students get daily practice questions and study tips. Teachers get curriculum resources and teaching strategies.

Typically responds within 24 hours

Message Sent!

Thanks for reaching out. I'll get back to you within 24 hours.

🏫 Welcome, fellow educator!

I offer curriculum resources, practice materials, and study guides designed for AP CS teachers. Let me know what you're looking for — whether it's classroom materials, a guest speaker, or Teachers Pay Teachers resources.

Email

[email protected]

📚

Courses

AP CSA, CSP, & Cybersecurity

Response Time

Within 24 hours

Prefer email? Reach me directly at [email protected]