title: How would I make the application add all the values of the integers in the arraylist so I could find the median of each grade?
body: <pre><code>import java.util.*;
  import java.io.*;
  
  public class Main {
  
      public static void main(String[] args) {
  
          Scanner scanner = new Scanner(System.in);
          System.out.print(&quot;How many grades do you want to input: &quot;);
  
          int amount = scanner.nextInt();
          int i = 0;
  
          ArrayList&lt;Integer&gt; myList = new ArrayList&lt;&gt;();
  
          Scanner sc = new Scanner(System.in);
          while (i &lt; amount) {
              System.out.print(&quot;Enter a grade (between 0 and 100): &quot;);
              myList.add(sc.nextInt());
              i++;
          }
  
          int highestNumber = Collections.max(myList);
          int lowestNumber = Collections.min(myList);
  
          System.out.println(&quot;The highest grade is: &quot; + highestNumber);
          System.out.println(&quot;The lowest grade is: &quot; + lowestNumber);
      }
  }
  </code></pre>