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
you are using `System.out.print()` instead use System.out.println();

`print()` will just print the word and stays on the same line.

`println()` will print the whole line and cursor goes to second line . 

And don't use the spaces while reading as you are writing it as

`input.next();` 

> 
> The next() and hasNext() methods and their primitive-type companion methods (such as nextInt() and hasNextInt()) first skip any input that matches the delimiter pattern, and then attempt to return the next token. Both hasNext and next methods may block waiting for further input. Whether a hasNext method blocks has no connection to whether or not its associated next method will block.
> 
> 
> 

**edit:**
just change the declaration to this.

```
 Scanner s = new Scanner(input).useDelimiter("\n");

```

It will change the delimiter to new line and read the complete line.