A G5 Mac can certainly run 10.4, but copies of it are hard to find, and are very expensive. It would also be possible to run 10.5 Leopard, and again these copies are expensive. If you went for 10.5 adding RAM may also be neccessary, which is an added expense.
Check out eBay to get some idea of price and availability.
What sort of G5 do you have? Click on the About this Mac for details.
Mac OS X 10.5 Leopard installation system requirements
Look on eBay or Google the installer part numbers to possibly find at an on-line store. Here's what to look for:
MB427Z/A Leopard 10.5.1 install DVD
MB576Z/A Leopard 10.5.4 install DVD
MB021Z/A Leopard 10.5.6 install DVD (single user)
MB022Z/A Leopard 10.5.6 install DVD (5-user family pack)
Installing Mac OS X 10.5 Leopard
Mac OS X 10.5 Leopard Installation and Setup Guide
After you install the base 10.5, download & install the 10.5.8 combo update at http://support.apple.com/downloads/Mac_OS_X_10_5_8_Combo_Update
The DVD should look like this
Caution - Leopard does not support classic mode. So, if you currently open OS 9 apps in classic mode, you won't be able to do this if you upgrade to Leopard.
Tiger install DVDs are in short supply. Do a Google search for MA453Z/A (10.4.6), MA190Z/A (10.4.3) and M9639Z/A (10.4). Also look on eBay. Be sure & buy a retail version (black with silver X)
and not a model specific version (gray) (See http://discussions.apple.com/thread.jspa?threadID=1976068 Can I use another Mac's system restore disc on my Mac?.
Possible Alternative if you are currently using Panther 10.3 – Do a Google search for Tiger 10.4 Upgrade DVD . It will upgrade your 10.3 to 10.4, but it doesn’t contain the full retail Tiger installer. Should be cheaper than the retail Tiger install DVD.
After you install the base 10.4.x, update to the final Tiger version 10.4.11. Here's the link for the 10.4.11 combo update http://support.apple.com/kb/TA24901?viewlocale=en_US
Look at this link Mac OS X v10.4 Tiger Installing Software Support Page
You can also download the Tiger Installation and Setup Guide
When you upgrade the OS, do it via Archive & Install. See About the Archive and Install feature http://support.apple.com/kb/HT1710
Be sure to select Preserve Users & Settings. Also, repair permissions before and after the install.