iPhone 5 randomly turns off

The other day my iphone would randomly just shut off and when turning it back on it says my battery was dead and gave me the connect to power icons. When I did and tried to reset it, it would just shut down again. This happened a few times. The phone said that it had like 30% battery left

A number of threads on the topic exist with some more information about it all that might be of some help (although it doesn't seem there are any specific solutions that really work for everyone), one of the more recent ones is at http://forums.macrumors.com/showthread.php?t=1659435

MacRumors attracts a broad audience
of both consumers and professionals interested in
the latest technologies and products. We also boast an active community focused on
purchasing decisions and technical aspects of the iPhone, iPod, iPad, and Mac platforms.