/** Find maximum of an array of integers
 *  Tue Feb 28 2006
 */
public class MaxLoop
{
  public static void main(String[] args)
  {
    int maxCans = 0;
    int[] cansSold = {185, 992, 370, 485, 209,
                      128, 84, 151, 32, 563};

    for (int i = 0; i < cansSold.length; i++)
    {
      //if (Math.max(cansSold[i] > maxCans) {
      //        maxCans =  Math.max(cansSold[i]);
      //}
      // Our first try to write this in class, above, used max
      // unnecessarily. A cleaner solution is to test cansSold vs. 
      // maxCans directly!

      if (cansSold[i] > maxCans) {
              maxCans = cansSold[i];
      }
    }
    System.out.println("We've sold a maximum at one location of " + maxCans
                       + " cans of pop");
    
  }
}

