0

i have this function, its suposed to allow you to register a new product line by line and then it inserts the object in the binary tree, but for some reason it skips the insert the name part and i cant insert it

    public static Produto insertnew(Product head) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("insert the product code");
        int code = scanner.nextInt();
        System.out.println("insert the current in stock quantity of this product");
        int instock = scanner.nextInt();
        System.out.println("insert a name for this product");
        String namep = scanner.nextLine();
        System.out.println("insert a brand for this product");
        String brand = scanner.nextLine();
        System.out.println("insert a category for this product");
        String category = scanner.nextLine();
        System.out.println("insert a price for this product");
        float price = scanner.nextFloat();
        return head = inserir(head, code, instock, namep, brand, category, price);
    }

this is the output and input:

insert the product code
45
insert the current in stock quantity of this product
10
insert a name for this product
insert a brand for this product
dell
insert a category for this product
eletronic
insert a price for this product
100,50

does anyone know where the problem is or how to fix it?

i tried changing the name to namep in case name was a reserved word in java, but it didnt work i searched for similar questions in this forum but none worked for me

0 Answers0