Added a function to calculate profit for a Program.