well hi guys new to the forum and i need some help

im writing a program where a guest’s name is entered and then assigned to a room. The motel has three floors and 30 rooms thus im using a 2D array (arr[3][10]) its supposed reserve a room and the room cannot be reserved again under a different name.

hope u can help
Tej

Fill the correct spot when someone wants a room:

Someone wants room 20 on floor 5:

array[5][20] = "Persons name";

What's the question anyway?

thanks for the new insight but i still have one other problem how do i stop a person from booking the same room again

-tej

To check if someone is already in the room use the following code:

boolean isRoomOccupied(int floor, int room)
{
   if( array[floor][room] == null )
      return true;
   else
      return false;
}

When someone checks out call this function

void checkOut(int floor, int room)
{
    array[floor][room] = null;
}

It is very important that you reset it back to null when it is check out time otherwise the first function won't work (because it checks for null)

For more help, www.NeedProgrammingHelp.com

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.