title: My grocery store bill program adds an unneccessary small numberto the total
body: <p>I remember this is a problem I can run into, but I forget why. Here's my code.</p>
  
  <pre><code>import java.util.Scanner;
  
  public class GroceryTab
  {
  
      public static void main(String[] args) 
      {
           double total = 0;
           int items = 0;
  
          System.out.print("How many different products are you buying?");
          Scanner in = new Scanner(System.in);
          items = in.nextInt();
  
          for(int i=1; i&lt;=items; i++) {
              double price;
              int numberBought;
              System.out.print("What is the price of your " + i +"th item?");
              Scanner priceIn = new Scanner(System.in);
              price = priceIn.nextDouble();
  
              System.out.print("How many of this item are you buying?");
              Scanner numIn = new Scanner(System.in);
              numberBought = numIn.nextInt();
  
              total += (price * numberBought);
          }
          System.out.print("Your list costs " + total + " dollars.");
      }
  }
  </code></pre>
  
  <p>Here's the weird part. I was testing it out, and I put in the following:</p>
  
  <p>How many different products are you buying?2</p>
  
  <p>What is the price of your 1th item?30.32</p>
  
  <p>How many of this item are you buying?3</p>
  
  <p>What is the price of your 2th item?.01</p>
  
  <p>How many of this item are you buying?3</p>
  
  <p>and got</p>
  
  <p>Your list costs 90.99000000000001 dollars.</p>
  
  <p>Whoops! What did I do to earn this?</p>