title: Iterate through list of objects & methods using for loop
body: <p>The entirety of the code can be found at the bottom of this post, but the only part that really concerns me is,</p>
  
  <pre><code>for(zed = 0; zed&lt;photoes.size(); zed++) {
  totesPrice += photoes&lt;zed&gt;.getCost();
  totesSize += photoes&lt;zed&gt;.getMegabytes();
  totesSpeed = photoes&lt;zed&gt;.getSpeed();
  }
  </code></pre>
  
  <p>Ideally the totesPrice, totesSize, and totesSpeed would be the sum of the get methods for the objects stored in the photoes list array. </p>
  
  <pre><code>// Import classes for class
  import java.util.Arrays;
  import java.util.List;
  import javax.swing.*;
  import java.awt.event.*;
  import java.text.DecimalFormat;
  import java.util.ArrayList;
  
  public class DigitalMain
  {
    public static void main(String args[])
    {
      String cont = "Y";
      String heightString,width,bitpsString = "";
      String widthString = "";
      int zed;
      double bitps,pHS,pWS = 0.0;
      double totesSpeed = 0.0;
      double totesPrice = 0.0;
      double totesSize = 0.0;
      DecimalFormat wholeDigits = new DecimalFormat("0");
      DecimalFormat dec = new DecimalFormat("0.00");
  
      List&lt;DigitalPhoto&gt; photoes = new ArrayList&lt;DigitalPhoto&gt;();
      do
      {
      DigitalPhoto photo = new DigitalPhoto();
      heightString = JOptionPane.showInputDialog("Please enter height");
      pHS = Double.parseDouble(heightString);
      photo.setHeight(pHS);
      widthString = JOptionPane.showInputDialog("Please enter width");
      pWS = Double.parseDouble(widthString);
      photo.setWidth(pWS);
      JOptionPane.showMessageDialog(null, "Height: " + photo.getHeight() + "\nWidth: " + photo.getWidth() + "\nResolution: " + photo.getResolution() + " DPI\nCompression Ratio: " + photo.getCompression() + "\nRequired Storage: " + dec.format(photo.getKilo()) + " Kilobytes.\nPrice of Scanned Photo: $" + dec.format(photo.getCost()) + " dollars.");
      do
      {
      bitpsString = JOptionPane.showInputDialog("Please enter your internet connection speed in BITS not BYTES please.");
      bitps = Double.parseDouble(bitpsString);
      } while (bitps &lt; 0 &amp;&amp; bitps &gt; 99999999);
      photo.setSpeed(bitps);
  
      for(zed = 0; zed&lt;photoes.size(); zed++) {
      totesPrice += photoes&lt;zed&gt;.getCost();
      totesSize += photoes&lt;zed&gt;.getMegabytes();
      totesSpeed = photoes&lt;zed&gt;.getSpeed();
      }
      cont = JOptionPane.showInputDialog("\nType \'Y\' to try again or anything but \'Y\' to use values.");
      photoes.add(photo);
      } while (cont.equalsIgnoreCase("Y"));
  
  
  
  
  
      double seconds = transferTime(totesSize, totesSpeed);
      double minutes = seconds / 60;
      double realsec = seconds % 60;
  
      JOptionPane.showMessageDialog(null, "You will be paying: " + totesPrice + "\nRequired Storage is: " + totesSize + "Required time for transfer is: " + wholeDigits.format(minutes) + " minutes, and " + wholeDigits.format(realsec) + " seconds.");
  
    }
  
    public static double transferTime(double totalStorage, double netSpeed) {
      double bits, seconds;
      bits = (totalStorage * 8);
      seconds = (bits / netSpeed);
      return seconds;
      };
  }
  </code></pre>