you most likely already answered when you stated "About two years ago the power went off a lot while the computer was being used".
Abrupt power surges tend to shorten the life of electronic equipment. This is different than simply pushing the on/off switch which does not cause any power surge.
You answered Bob that your computer is cleaned, but besides damaged components heat can also cause the symptoms you mention. You can generally rule either for or against a heat problem by opening the case and directing a floor fan into the case so it blosw across the motherboard, CPU and all other components. If the problem remains you have ruled out heat but if the problem goes away you have narrowed the problem to heat and just need to find the component. Quite often the culprit is a lack of thermal paste between the processor and the heatsink/fan or more rarely an overheating hard drive.
Try the fan and get back to us.