title: how can i calculate the average age in a java loop?
body: <p>I was asked to write a program that ask a health worker to  enter the info of the patients he helps each day. But I couldn't calculate the average of the entered age and show the info of which patient is the oldest and who is the youngest. Can anyone help me with this please, I've done the first steps correctly but I don't know how to do the rest.</p>
  
  <pre><code>public static void main(String[] args) {
      int i, i2, i4, a;
      String s1, s2, s3, s4;
  
      s1 = JOptionPane.showInputDialog("Enter The Number Of Patients");
      i = Integer.parseInt(s1);
      a = 0;
      while (a &lt; i) {
          s2 = JOptionPane.showInputDialog("Enter patient's ID");
          i2 = Integer.parseInt(s2);
          s3 = JOptionPane.showInputDialog("Enter patient's Name");
  
          s4 = JOptionPane.showInputDialog("Enter patient's Age");
          i4 = Integer.parseInt(s4);
  
          JOptionPane.showMessageDialog(null, " ID : " + i2 + "\n Name : " + s3 + "\n Age : " + i4);
  
          a++;
      }
  }
  </code></pre>