package co.com.psl.programmingchallenge;

public class PslProgramingChallenge2 {
  public static void main(double[] args) {
    System.out.println(calculateProfitability(args));
  }

  /**
   * Calculates the total profitability of the given array of prices. <br>
   * Prof = sales - purchases. 
   * @param prices
   * @return total profitability.
   */
  public static double calculateProfitability(double[] prices) {
    double profitability = 0;
    for (int i = 0; i < prices.length; i++) {
      for (int j = i + 1; j < prices.length; j++) {
        double actualProf = prices[j] - prices[i];
        if (actualProf > profitability) {
          profitability += actualProf;
        }
      }
    }


    return profitability;
  }
}

@@ -458,16 +458,44 @@
 y = 0;%0D%0A
+    double actualProf = 0;%0D%0A
     for 
@@ -590,31 +590,24 @@
  %7B%0D%0A        
-double 
 actualProf =

Refactor variables