exercise when hurt?

My knees and back hurt moderately, so I am hesitant to exercise. At the same time, I am scared not to exercise for fear of loosing weight. I have consumed 124 calories less than my daily goal to compensate in case I don't exercise, but I still mentally feel compelled to exercise despite knowing that my cardiovascular exercises (CrossRamp and maximum incline on treadmill) are high impact on my legs. What should I do?