I suspect the problem is with the battery, but the System Management Controller (SMC) may need to be reset. Here's how to do it: Before resetting the SMC, try these steps:
# Shut down your Mac.
# Press and hold the power button for 10 seconds, then release the button.
# Wait a few seconds, then press the power button to turn on your Mac.
If the problem persists, follow these steps to reset the SMC:
# Shut down your Mac.
# On your built-in keyboard, press and hold all of the following keys. Your Mac can turn on. Control on the left side of your keyboard. Option (Alt) on the left side of your keyboard.
# Shift on the right side of your keyboard Hold down all three keys for 7 seconds, then also hold down the power button. If your Mac is on, it will turn off when you hold down the keys.
# Hold down all four keys for an additional 7 seconds, then release them.
# Wait a few seconds, then press the power button to turn on your Mac.
If that doesn't do the trick, you should take it to the Apple Store when you can.