Summarize:

In your hamster’s last days, make him as happy as possible. Put soft material in his cage. Let him sleep as much as he wants. Put his favorite toys in his cage. Your hamster may lose energy and may not participate in its usual exercise. You do not want to make him excessively tired by holding him. Talk to your vet or parents about what diet would be best. If your hamster is suffering from heart damage, for example, you may want to avoid fatty foods like sunflowers. Teeth issues can also plague older hamsters. Try feeding him soft foods like rice or cereal.
Make your hamster comfortable. Avoid excessive holding. Feed and water appropriately.