Maximum Profit or Loss in Stock Trading (Java)