title: Varied amounts of input data
body: <p><strong>Problem:</strong> Statistics are often calculated with varying amounts of input data. Write a program that takes any number of non-negative integers as input, and outputs the average and max. A negative integer ends the input and is not included in the statistics.</p>
  
  <p>Ex: When the input is:
  15 20 0 5 -1</p>
  
  <p>the output is:
  10 20</p>
  
  <p>You can assume that at least one non-negative integer is input.</p>
  
  <pre><code>import java.util.Scanner; 
  
  public class LabProgram {
     public static void main(String[] args) {
  
        Scanner scnr = new Scanner (System.in);
        int num = 0;
        int count = 0;
        int max = 0;
        int total = 0;
        int avg = 0;
  
       do {
  
           total += num;
           num = scnr.nextInt();
           count = ++count;
  
  
           if (num &gt;= max) {
              max = num;
           }
  
        } while (num &gt;= 0);
  
       avg = total/(count-1);
  
        System.out.println(avg + " " + max);
  
     }
  }
  </code></pre>
  
  <p>I had a lot of trouble with this problem. Is there any way I could have done this without having to do count -1 while computing the average?
  Also, is this this the most efficient way I could have done it?</p>