title: Java calculate percentage based on items in array list
body: <p>I was having some problem when trying to calculate the percentage based on an array list.</p>
  
  <pre><code>int total = 0;
      double percentage = 0;
      for(int i = 0; i &lt; accountList.size(); i++){
          total += Integer.parseInt(accountList.get(i).getTotalCount());
      }
  
      for(int j = 0; j &lt; accountList.size(); j++){
          percentage = Math.round(Double.parseDouble(accountList.get(j).getTotalCount()) / (double)total);
          Log.i("PCT", String.valueOf(percentage));
      }
  </code></pre>
  
  <p>Basically the first loop is to calculate the total. Then as for second loop, I am looping each items in the array list divided by the total to get the percentage. </p>
  
  <p>However, when I try to print out the percentage, I am getting 0.0. But then when I print out the total, it did returned me the total.</p>
  
  <p>Any ideas?</p>
  
  <p>Thanks in advance.</p>