I would suggest battery replacement, During a battery's lifetime it's peak voltage and capacity decline. The charge sensor is not built to register the decline in power and after around 2-5 years the battery cannot provide the required voltage, causing the phone to power off. After this, because of the voltage decline (how batteries percentages are measured) the phone assumes that it has much less charge than than it actually contains
Hope This Helps :)