package cumpa;

import javax.sound.midi.Soundbank;
import java.util.Scanner;

public class App {

    //App variables
    private static String appName = "Our Groceries";
    private static double appVersion = 0.1;

    //Input scanner
    private static Scanner scanner = new Scanner(System.in);

    //our grocery item
    private static String itemName;
    private static String itemCategory;
    private static double itemUnitPrice;
    private static int itemUnits;
    private static double itemTotalPrice;

    private static void initApp(String name, double ver){
        System.out.println("Initializing " + name + " version " + ver);
    }

    private static void getItemDetails(){
        System.out.println("Initializing " + appName + " version " + appVersion);
        System.out.println("=== Input item details ===");
        System.out.print("Name: ");itemName = scanner.nextLine();
        System.out.print("Category: ");itemCategory = scanner.next();
        System.out.print("Unit Price: ");itemUnitPrice = scanner.nextDouble();
        System.out.print("Units : ");itemUnits = scanner.nextInt();
        System.out.println("======= End input ========");

        // some logic after input
        itemTotalPrice = itemUnitPrice * itemUnits;

    }

    private static void showItemDetails(){
        System.out.println("=== Our product ===");
        System.out.printf("Name: %s \n",itemName);
        System.out.printf("Category: %s \n",itemCategory);
        System.out.printf("Unit proice: %s \n",itemUnitPrice);
        System.out.printf("Total units: %s \n",itemUnits);
        System.out.printf("Total price: %s \n",itemTotalPrice);
        System.out.println("===================");
    }

    public static void main(String[] args) {

        initApp(appName,appVersion);

        //getItemDetails();
        //showItemDetails();

        getItemDetails();

        for (int i=0;i<10;i++){

            System.out.println("I am " + i);
            showItemDetails();

        }

        System.out.println("Application finished");


    }

}

@@ -691,90 +691,8 @@
 ()%7B%0A
-        System.out.println(%22Initializing %22 + appName + %22 version %22 + appVersion);%0A
     
@@ -877,16 +877,20 @@
 ner.next
+Line
 ();%0A    
@@ -1028,24 +1028,52 @@
 .nextInt();%0A
+        scanner.nextLine();%0A
         Syst
@@ -1811,33 +1811,272 @@
         
-getItemDetails();
+int numberOfItems;%0A%0A        System.out.print(%22How many items do you want to input: %22); numberOfItems=scanner.nextInt();%0A        scanner.nextLine(); // this is needed because nextInt does not consume the new line character and the next input will be skipped
 %0A%0A      
@@ -2096,10 +2096,21 @@
 0;i%3C
-10
+numberOfItems
 ;i++
@@ -2149,18 +2149,59 @@
 ln(%22
-I am %22 + i
+### Enter item  %22 + i);%0A            getItemDetails(
 );%0A 

Read a number of items established at the begining of the pp