Corrected bug in calculation of periodic payment where the if statements referred to case instead of frequency.