Long answer:
Rub all the contactd points with a pencil eraser to polish them, then clean them with a bit of 90% alcohol.
Usually, the problem is with the battery or in the power adapter, or the contact points between the battery and the computer. However, you can have a bad socket, so see if you detect any looseness of movement in the socket into which you plug the power adapter.
17% of laptop batteries go back while still under warranty, while others just get hung up. It is often helpful to intentionally discharge the battery, then try again to recharge it.
The battery has a chip buit into it. This chip tracks the charges and discharges. It is a safety feature. When it reaches the maximum number of charges, it will no longer work, even if still less than a year old. If you have allowed the battery to discharge down to 4% frequently, it is dead.
Short Answer: Replace the battery. If that doesn't work, replace the power adapter.