I used to have pretty terrible posture when I was younger, but eventually I had a crazy French teacher at school who would dock you points if you were slouched over your desk, leaning your head on your hands, etc.
I just had to keep telling myself to sit up straight, and after a while it just came naturally. So, I guess really my only advice would be to just keep reminding yourself not to slouch. And if you catch yourself doing it, sit up straight. Eventually you'll sit straight everytime, and it really is better for you in the long run.