A program based on the simulated annealing (SA) algorithm was developed to allow for a longer-term prediction of the occurrence of solar flares, thus reducing the risks they may pose to astronauts, satellites, and ultimately the planet Earth. Sunspot data such as the solar cycle, the appearance of sunspots, the sun's magnetic field, the occurrence of solar flares and other factors that concern the sun were considered in the development of the algorithm. The program, coded in C++, included providing for an initial random state that pertained to the sun's state at a specified time. A neighborhood function was designed based on how sunspots are formed and how they disappear, and the probability function was designed using previous solar cycles to show relationships between the number of sunspots and the time it takes for the sun to reach solar maxima. Finally, the cooling function was designed as a representation of the time. Recorded sunspot counts obtained from the US National Geophysical Data Center (NGDC) during the solar cycle 22 from 1986 to 1996 was used as test data. The output was compared to the actual recorded solar events or the period. The program was found to be 66.7% accurate in predicting solar flares when compared on a smoothed trendline, while it exhibited a 50.5% accuracy when comparing day-to-day data. Since solar flare acitivty is predicted in terms of the trend of activity and intensity, improving daily data accuracy is superfluous. Smoothed trendline prediction accuracy may however be improved by altering the importance of each factor in predicting solar flare activity and by devising a different sunspot classification scheme for intensity and activity.