I have a three year old who we have struggled with her whole life! I have never really found the answer, luckily in the summer she goes outside all the time so that is a great break! Lately she has been getting good about using the litter boxes, but sometimes she still goes on the floor, we've been using repellant sprays and trying to catch her in the act, a sharp word will get her to stop whatever she is doing, but it is HARD!
I also have this girl that lives on top of my fridge, LITERALLY, she only goes off the fridge to sneak outside to potty. She seems to be afraid of all the other cats so she stakes out the kitchen and if she doesn't see any cats she will jump down to the floor really quick and sneak around the edges of the walls til she gets to the cat door where she quickly sneaks out! Coming back in is just as big a hassle. When another cat sees her they try to chase her and she will run back into the cabinets, once or twice she went IN a cabinet, we started putting her out twice a day, she LET us pick her up and throw her out. After a couple days of this she seemed to get the idea and now is VERY good about going outside, If she had continued using CABINETS I would have gotten rid of her!