title: Java ArrayList: Utilising ArrayList for print message
body: <p>In my Java program I have an ArrayList. What I want to do is print a number at the bottom that will say 'x amount of people have passed' </p>
  
  <pre><code>System.out.println = ("The amount of people that have more than 40 marks is " + x);
  </code></pre>
  
  <p>Is it possible to calculate how many numbers of marks will be more than 40 if there are an undetermined amount of marks put in, utilising an ArrayList?</p>
  
  <pre><code>public class test {
  
  /**
   * @param args the command line arguments
   */
  public static void main(String[] args) {
  
      ArrayList&lt;Integer&gt; marks = new ArrayList&lt;Integer&gt;();
  
      Scanner input = new Scanner(System.in);
      // Create a new scanner to use in java
  
      int[] range  =  { 0,29,39,69,100 };
      // A new array is created with the grade boundaries
      int[] inRange = new int[boundary.length - 1];
      // Indexed from 0 to n-1
  
      int markIn;
      // New integer markIn
      do {
      // This do-while loop calculates the expression after the statements below are exectued at least once
          System.out.println("Enter Mark(s):");
          // Wait for user input
          markIn = input.nextInt();       
          // markInp value is set as the value entered by user
          marks.add(markIn);
  
          for (int a=1 ; a&lt;boundary.length ; a++)
          // for loop will take the variable 'a' and compare it with varibale 'boundary', when the condition is satisfied that value of 'a' increments by 1
             if (range[a-1] &lt;= markInp &amp;&amp; markInp &lt;= range[a]) {
             // The boundaries will define the upper and lower limits of the markInp
                 inRange[a-1]++;
                 //inRange is incremented by 1
                 break;
                 //Exit if
             }
      } while (markIn &lt;= 100);
      // When the mark exceeds 100, the loop is stopped
  
      System.out.println(marks);
  
      input.close();
  }   // Close the Scanner input
  }
  </code></pre>