Fifteen. That is the cap, and the sixteenth shelf does nothing at all.
How to place them
Shelves must sit exactly one block away from the table with air in the gap, at the same level as the table or one block higher. A torch, a carpet, a slab or a stray block in that gap stops the shelf counting, which is the single most common reason a build that looks right still only offers level 8.
The standard layout is a ring of shelves around the table with one gap to walk through: five shelves on each of three sides at floor level, and the same again one block up, gives you more than enough. Leave the entry gap on the fourth side.
Crafting the shelves
Each bookshelf is six wooden planks and three books, and each book is three paper plus one leather. Fifteen shelves means 45 books, so 135 paper and 45 leather. Sugar cane farms and cow pens are the bottleneck, not wood.
Do not build it out of chiselled bookshelves
Chiselled bookshelves are a different block. They store books for redstone purposes and do not boost an enchanting table at all. Use the plain version.
What level 30 actually buys you
It unlocks the strongest offers the table can produce — Sharpness V, Protection IV, Efficiency V, Power V and so on. It does not unlock treasure enchantments, which never appear at a table regardless of shelf count. See the full enchantment list for which ones need trading or loot instead.
Once you have your books, the enchantment calculator works out the cheapest order to combine them so the anvil does not price you out halfway through.