My iphone battery percentage is misleading? How do I fix this?

My iphone will be charged to a 100% and then with about an hour or so of usage will drop to about 70% ish, and all of a sudden it would turn of with an Icon saying I need to charge the battery. And then i'll charge it, it'll turn back on and the battery percentage would be at 80%. Now this doesn't just happen at 70% but it fluctuates to any random percentage of charge. Now you'll say just replace the battery and it'll be fine but I already replaced the battery and i'm still having the same issues. What is wrong with it and what do I need to do?? Can someone please help me.
Without knowing which iPhone you are using and how old it is, my suggestion would be to contact Apple or bring it into the Apple Store.

Original thread: https://forums.imore.com/threads/my-iphone-battery-percentage-is-misleading-how-do-i-fix-this.381634/