How can I exercise with a total knee replacement?

With advise. You can exercise after knee replacement, and it is a good idea. The best exercise is that which avoids stress across the knee. Although you want to strengthen the muscles around the knee, you do not want to place undue stresses across the replaced knee. Your orthopedist and your physical therapist can best advise you.
Low impact. The type of exercise depends on the timing following knee replacement. Initially, one focuses on range of motion exercises and learning how to walk properly. Following the immediate recovery period, one focuses on low impact quadriceps strengthening exercises. Good exercises are riding a stationary bike, elliptical machines and swimming.
Many ways. The only major restriction on exercise for total knees would be to avoid jogging or running as your aerobic exercise. Jumping and landing exercise are also not great because like jogging, you can cause loosening of the implant from the bone or cement fixation. This also can speed the wear down of the plastic bearings. Bicycles, tai chi, walking, swimming, dancing, golf, tennis, ellipticals good.
Low impact. After a total knee replacement, any type of impact activity is not advised. This includes jumping, jogging, hopping, etc. It is believed that these activities may shorten the lifespan of the implants. I suggest my patients pursue constant, repetitive, low stress exercises such as swimming, walking, and biking. High reps with low resistance is always a good rule, as well as avoiding deep squats.