A laptop that dies at 40% does not always need a new battery. Check these five things first, in order, before ordering a replacement.
1. Check the battery health report. On Windows, run powercfg /batteryreport and look at the design capacity against the full charge capacity. If the full charge is above 70% of design, the battery is probably not the problem.
2. Test with a different charger and a different wall outlet. A charger that cannot deliver its rated wattage makes a good battery look dead.
3. Look at what is running. Open Task Manager, sort by power usage, and check whether one app is draining the battery in the background.
4. Check the power settings. A performance plan that never sleeps the machine will drain any battery, new or old.
5. Check the battery itself. Swelling, a case that no longer sits flat, or a trackpad that clicks differently can mean a swollen battery, and that is a safety issue, not a shopping decision. Stop using it and get it checked.
If all five checks point to the battery, then replace it, and use the battery health report to confirm the new one holds its design capacity in the first week.
This checklist covers common cases; it does not replace a diagnosis for a machine that gets hot, smells, or shuts down without warning.
Source: Microsoft Windows battery report documentation