Apple iPhone 3GS Battery Problem So my iPhone is charged at 100% overnight, and when the battery gets to like 90%, the phone suddenly shuts off when I open an app like Facebook, Foursquare, Maps, etc... 

I try turning it back on and the Apple logo appears. When it gets to the lock screen, the battery is still showing 90% but then the phone decides to turn off again. I can turn it back on, and the same thing happens. Occasionally, it'll get past the lock screen, but after I launch an app, the phone decides to shut off again. After a couple of on/off cycles (the battery still showing >80%), the phone decides to give up and displays the low battery/plug into charger icon, even when it said it had 80% battery a minute ago.

Anyone have the same problem and know a solution?
The solution is likely to get the battery replaced.  By Apple or a qualified repair service.  

Li-Ion batteries behave like this when the chemistry fails due to normal use or a premature fault.  The voltage can suddenly drops off a cliff, too fast for the battery charge indicator to show the decrease in percentage.