I work in animal rescue, and I'm sorry to say that your case is not unique. In fact, I own a cat that we have never been able to train to use just the litterbox (no health problems, just emotional ones), and I understand how, after a while, it just becomes such a stressful situation! When it comes to cleaning the carpets, if the cats have just peed in small spots, invest in a blacklight (petstores sell them) and find the spots. Then apply an enzyme-cleaner (I highly recommend - and no, I'm not kidding - Anti-Ickypoo http://www.antiickypoo.com/ as a strong enzyme cleaner). If you cat has really soaked the area, though, there isn't much you can do besides ripping up the carpet and pad and starting again.
However, before you give your cat up, please realize that no one else wants a cat that pees in their house, either - cats that pee in the house are usually put down if they end up in shelters. Instead, I recently sent an email to another woman, and so I have copied the advice I sent to her. There are a couple of things I have learned about this:
Try taking your cat to a specialist or going to a cat-only vet (someone who runs a cat hospital or specializes in just cats) in your area and talking to them about different types of antibiotics and kitty prozacs. With my cat, we were able to put her on something called amatryptaline (I'm sure I've spelled that wrong), which was just a cream to rub into her ears, and it made a HUGE difference! She was like a different cat! It actually solved the peeing problem for several years, until my son was born, and then it didn't work any longer.
I also recommend http://www.catsinternational.org/ which is not only a helpful website, but they also have a free "cat behavior hotline" that you can call, leave your phone number, and they will call you back and help you address your problems. I found them very helpful, and really, it is completely free.
As a final ditch effort, we bought a large cat crate (do a search on amazon.com for cat crates - there are several good-sized ones for a decent price - I purchased one that is 3-tiers high!) and we keep my cat in it when we cannot be in the room with her to supervise her. She has her own litterbox, food, and water, and a nice, soft bed. At first, I felt very guilty about crating a cat permanently (we often crate them in rescue for a couple of months, but the intention is that they will eventually have run of a home), but perhaps because of her age, she really doesn't seem to mind it. In fact, during the hours when we let her out, about half the time she still chooses to remain in the crate. I think this is a last resort for a cat owner, but I will admit that my own relationship with the cat has improved because I am no longer stressing and sniffing at rooms when I enter them. And as my vet put it, not only is it effective litterbox training, but it sure beats taking her to the shelter! It is also a lot less expensive than repeatedly replacing the carpet (I had to replace the carpets in two rooms of my new house, and I know that it is both expensive and really irritating).
I hope this has been helpful. A cat peeing in the house is extremely stressful. I am glad you are doing your best to find a solution instead of trying to find the cat a new home. Just know that there are solutions out there, even if nothing is ideal. Good luck.