title: Getting cannot find symbol errors. ArrayLists, Iterator
body: <p>A supermarket wants to reward the top customers of the day, that is, the topN customers with the largest sales, where topN is a value that the user of the program supplies, showing the customer’s name on a screen in the supermarket. For that purpose, the customer’s purchase amount is stored in an ArrayList
  
  <p>Implement a method: public static ArrayList
  
  <p>Write a program that prompts the cashier to enter all prices and names, adds them to two array lists, calls the method that you implemented, and displays the result. Use a price of 0 as a sentinel.</p>
  
  <p>My errors when compiling are:</p>
  
  <pre><code>------ Compile ----------
  hw1num2.java:44: error: cannot find symbol
                  double check = iter.nextDouble();
                                     ^
    symbol:   method nextDouble()
    location: variable iter of type Iterator
  hw1num2.java:45: error: cannot find symbol
                  if (check&gt;=sorted(topN-1))
                             ^
   symbol:   method sorted(int)
  location: class hw1num2
  hw1num2.java:47: error: no suitable method found for add(double)
                      topCust.add(check);
                             ^
     method ArrayList.add(int,String) is not applicable
      (actual and formal argument lists differ in length)
   method ArrayList.add(String) is not applicable
   (actual argument double cannot be converted to String by method invocatio&gt;n conversion)
  3 errors
  
  Output completed (1 sec consumed) - Normal Termination
  </code></pre>
  
  <p>Here's what I have:</p>
  
  <pre><code>import java.util.*;
  
  public class hw1num2
  {
      public static void main(String[] args) 
      {
          Scanner in = new Scanner(System.in);
          ArrayList&lt;Double&gt; sales = new ArrayList&lt;Double&gt;();
          ArrayList&lt;String&gt; customers = new ArrayList&lt;String&gt;();
  
          boolean end = true;
  
          while (end)  //Continues to take input for customer names and purchases until done
          {
              System.out.println("Enter the first name of the customer.");
              String cust = in.next();
              System.out.println("Enter the purchase total of that customer.");
              Double total = in.nextDouble();
              sales.add(total);
              customers.add(cust);
              System.out.println("Enter 1 if you have another customer to add, or 2 if you are done.");
              int choice = in.nextInt();
              if (choice != 1)
              {
                  end=false;
              }
          }
          System.out.println("How many top customers would you like to display?");
          int topN = in.nextInt();
          System.out.println(nameOfBestCustomers(sales, customers, topN));  //calls method that computes top custs
      }
  
      public static ArrayList&lt;String&gt; nameOfBestCustomers(ArrayList&lt;Double&gt; sales, ArrayList&lt;String&gt; customers, 
      int topN) //Finds out who the topN customers were
      {
          ArrayList&lt;Double&gt; sorted = new ArrayList&lt;Double&gt;(sales); //create copy of sales ArrayList
          ArrayList&lt;String&gt; topCust = new ArrayList&lt;String&gt;(); //create ArrayList to hold top cust names
          Collections.sort(sorted);  //sort the copied ArrayList.
          Iterator iter = sales.iterator();  
          while (iter.hasNext())  //iterate through sales ArrayList to find indexes of top purchases
          {
              for (int i=0;i&lt;sales.size();i++)
              {
                  double check = (double)iter.next(); 
                  if (check&gt;=sorted.get(topN-1)) //checks if each index is &gt;= the top Nth customer
                  {
                      topCust.add(customers.get(i)); //if so, adds it to topCust list
                  }
              }
          }
          return topCust;  //returns the list with the top customer names
      }
  }
  </code></pre>