title: java : How can i count number of even values in a list of numbers?
body: <p>What this program supposed to do is : the user should input the number of values and then get the average of even numbers in the list of values. I am stuck on where i need to get the number of even values to get the average.</p>
  
  <pre><code>import javax.swing.JOptionPane;
  
  class SumOfEven {
  
      public static void main(String args[])
      {
          int n;
          int sum=0;
          double avg;
          String Numbers;
          int even;
  
          Numbers = JOptionPane.showInputDialog("How Many Numbers In The List ??");
          n = Integer.parseInt( Numbers);
  
          for(int i=0;i&lt;=n;i++)
          {
              if(i%2==0)
              {
                  System.out.println("Number of Even Numbers In This List = "+i);
              }
          }
  
          for(int x=0;x&lt;=n;x+=2){
             sum+=x;
  
          }
  
          avg=sum/n;
          System.out.println("sum of even numbers is =" +sum);
          System.out.println("avgerage of even numbers is =" +avg);
  
          System.exit(0);
      }
  }
  </code></pre>