Should I replace the battery or is it the problem software related?

I have an iPhone 6 that shuts off at 40% or more. I have read about the issue affecting many iPhone 6/6s models, but I haven't read if the issue is software or battery. So before I go to the apple store and pay for a replacement, I would like to get your opinion if I should or will it be a waste of money?
It was certain iPhone 6s that were having problems and if your iPhone is one of the batch Apple were replacing the phones.
Welcome to iMore! The 6 is a two year old phone now. If it's had heavy use, the battery is likely waning. It will soon need replacing. I doubt it's software related.
It was certain iPhone 6s that were having problems and if your iPhone is one of the batch Apple were replacing the phones.

On the 6s, they were actually replacing the battery not the phones.

Original thread: https://forums.imore.com/threads/should-i-replace-the-battery-or-is-it-the-problem-software-related.383424/