Profit Maximization and Total Profit Calculation