My phone shuts off when it is not plugged in, then it shows a yellow triangle with a little red dot above it. Then you plug it back in it may have up to 98% charge,
It is a electronic device. It sounds like it has a defect. Must trouble shoot hardware, software.
Shutdown the phone and take the battery out for 5 minutes. Then with phone unplugged, put battery back in and start it. Depending on the out come you may have to take additional steps.
There is a hole lot of things a tech needs to know before a determination on defect.
Oh no we don't want your phone to shut off. I am sure I can help. How long has this been going on? Have you tried a different charger? Has there been any physical or moisture damage to the phone? AmberF_VZW