The problem will be triggered when adding product name with space, the program will treated it as two different entries. ====================================================================================== Please input your Worker ID for logging in the system... 1 Please input your Member ID for logging in the system... 1234 ---Welcome to Morx Supermarket--- ---To continue, please proceed your actions--- Input (1) for accessing Inventory System Input (2) for accessing Checkout System Input (3) for accessing Sales System Input (4) for accessing Membership System Input (5) for switching member Input (6) to exit 1 ---Hi ON9, Welcome to Inventory Management System.--- ---Input commands for further management--- Input (1) for addProducts Input (2) for deleteProducts Input (3) for check inventory Input (4) for exit 1 Please input the name for the new product: Fuji Apple Please input the category of the new product: Please input the brand of the new product:
The problem has been solved by using System.out.println instead of System.out.print. ====================================================================================== public void addProducts() throws ParseException { boolean isFalse = false; do { try { System.out.println("Please input the name for the new product:"); String productName = Tools.sc.nextLine(); System.out.println("Please input the category of the new product:"); String productType = Tools.sc.next(); System.out.println("Please input the brand of the new product:"); String productBrand = Tools.sc.nextLine(); System.out.println("Please input the food expire date / equipment warranty date in yyyy-mm-dd format"); String productDate = Tools.sc.next(); System.out.println("Please input the Marked Price for the new product:"); double markedPrice = Tools.sc.nextDouble(); System.out.println("Please input the quantity of the new product:"); int quantity = Tools.sc.nextInt(); inventoryFunction.createProduct(productName, productType, markedPrice, quantity, productDate, productBrand); System.out.println("Do you have any other actions to continue ?"); System.out.print("Please input (1) to continue \nPlease input (0) to exit\n"); isFalse = tools.continuationValidator(Tools.sc.nextInt()); } catch (Exception e) { System.out.println("*** Input Error! ***"); // for example, int field cannot input as string } } while (isFalse == false); }