package chapter5;

/**
 * Title:        Chapter 5, "Arrays"
 * Description:  Examples for Chapter 2
 * Copyright:    Copyright (c) 2000
 * Company:      Armstrong Atlantic State University
 * @author Y. Daniel Liang
 * @version 1.0
 */

import chapter2.MyInput;

public class TestArray
{
  /**Main method*/
  public static void main(String[] args)
  {
    int[] number = new int[6];

    // Read all numbers
    for (int i=0; i<number.length; i++)
    {
      System.out.print("Enter a new number: ");
      number[i] = MyInput.readInt();
    }

    // Find the largest number
    int max = number[0];
    for (int i=1; i<number.length; i++)
    {
      if (max < number[i])
        max = number[i];
    }

    // Find the occurrence of the largest number
    int count = 0;
    for (int i=0; i<number.length; i++)
    {
      if (number[i] == max) count++;
    }

    // Display the result
    System.out.print("The array is ");
    for (int i=0; i<number.length; i++)
    {
      System.out.print(number[i] + " ");
    }

    System.out.println();
    System.out.println("The largest number is " + max);
    System.out.println("The occurrence count of the largest number "
      + "is " + count);
  }
}