Basically I need to take my iPhone to the apple store tomorrow and I don't want it to be jailbroken. I need a easy way to do it, I am currently running on 3.1.3

I was thinking I should just upgrade to 4.0, but am not sure that will get rid of Cydia and all jailbroken features. Is there a way I can clean it out?
Instructions and tips would be useful
What about the apps that i've downloaded with Installous. Should i delete them from itunes? or do they not matter?