Question: I am inputting the following things:

* book
* 12.46
* music cd

For some reason, the prompt for cost comes up and the next output line comes on the same line. Could someone help me to spot my mistake?

```
public class SalesTax {

    public static void main(String[] args) {
        // Input items for shopping cart
        HashMap<String, String> cart = new HashMap<String, String>();

        // Create a Scanner
        Scanner input = new Scanner(System.in);

        // variables
        char done;
        boolean goods;
        double tax;

        // Pick items for list.
        do {       
            System.out.print("Please enter an item.");
            String item = input.next();

            System.out.print("Please enter the price for "+ item + ": ");
            String price = input.next();      

            if (item.contains("book")) {
                goods = false;  
            } else if(item.contains("chocolate")) {
                goods = false;
            } else if(item.contains("pill")) {
                goods = false;
            }

            cart.put(item, price);
            System.out.print("Would you like to continue to add items? (Type Y) for Yes and (Type N) for No.");
            done = input.next().charAt(0);

        } while(Character.toUpperCase(done) == 'Y');
    }
}

```

Answer: 
**problem:**

```
String item = input.next();

```

By the time you input `music cd` it will consume **music** by `item` and `price` will consume the **cd** thus skipping it.

**solution:**

you need to call `input.nextLine();` to consume the whole line of string
use `input.nextLine()` to read an entire line from the keyboard. Means what ever the user typed till the user presses the enter key.

One thing that I did not understand is, what is the use of having this in your code

```
        if(item.contains("book"))
        {
            goods = false;  
        }
        else if(item.contains("chocolate"))
        {
            goods = false;
        }
        else if(item.contains("pill"))
        {
            goods = false;
        }

```

???
Can you please explain?

Thanks,