public void addStock(Product[] products, Scanner sc) { int num=-1; System.out.println("How many values do you want to add: "); num = sc.nextInt(); while(num < 0) { System.out.println("Please enter only positive values!"); System.out.println("How many values do you want to add: "); num = sc.nextInt(); } for(Product p: products) { p.addQuantity(num); } }