Re: Skipping Input Problem
Hello Matty Alan,
Welcome to the Java Programming Forums.
I tested this and can see that it does indeed skip the last Name = Input.nextLine();
Upon further testing and reading about the Scanner class, the issue seems to be down to nextLine(); method.
Scanner (Java Platform SE 6)
If you update to:
Originally Posted by Oracle
System.out.print("Product Code: ");
Code = Input.next();
System.out.println("Product Discription: ");
Discription = Input.next();
Price = Input.nextDouble();
Quantity = Input.nextShort();
System.out.println("Sales Rep: ");
Name = Input.next();
Then it works fine.
But it doesn't solve the issue for the "Discription" variable.
I'm sure the description will contain more than one word and Input.next(); will throw a java.util.InputMismatchException if we try this.