title: Can I replace values on a single variable in Java
body: <p>I have program that the user picks their products in the product menu in which after they inputted the item ID and the quantity, the program will ask if they want to buy another, if YES then the transaction repeats again and asking the same question. My central question is can I replace the value in the single variable? </p>
  
  <pre><code>    Scanner id = new Scanner (System.in);
      String products [] = {"Donut", "Ice Cream", "Kitkat", "Marshmallow", "Nutella"};
      int prices [] = {25, 15, 40, 60, 150};
      int number [] = {0, 1, 2 ,3 , 4};
      char result [] = {'a', 'b', 'c','d'};
      System.out.println("                Menu                "); 
      System.out.println("Item ID\tItem Name\tPrice (Php)");
      System.out.println(number [0]+"\t"+products [0]+"\t\t"+prices[0]);  
      System.out.println(number [1]+"\t"+products [1]+"\t"+prices[1]);
      System.out.println(number [2]+"\t"+products [2]+"\t\t"+prices[2]);
      System.out.println(number [3]+"\t"+products [3]+"\t"+prices[3]);
      System.out.println(number [4]+"\t"+products [4]+"\t\t"+prices[4]);
      System.out.println();
      System.out.print("Select ID Number: ");
    int ID = id.nextInt();
      System.out.println("Input quantity: ");
    int QUANTITY = id.nextInt();
    System.out.println("Product ID: "+ID);
    int a = ID;
    System.out.println("Product Name: "+products[ID]);
    String b = products[ID];
    System.out.println("Quantity: "+QUANTITY);
    int c = QUANTITY;
    System.out.println("Product Price: "+prices[ID]);
    int d = prices[ID];
    System.out.println("Amount to be Paid: "+(QUANTITY * prices[ID]));
    int e = QUANTITY * prices[ID];
    System.out.println("Added to cart, want to buy another? [Y] [N]");
      char keys = id.next().charAt(0);
      switch (keys) {
      case 'Y':
          method6();
          break;
      case 'N':
          System.out.println("*******************************************************************");
          System.out.println("Item ID\tItem Name\tQuantity\tAmount");
          System.out.println(a+"\t"+b+"\t\t"+c+"\t"+e+"\t");
          System.out.println("*******************************************************************");
          int x = d;
          System.out.println("Total: "+x);
          System.out.print("Cash: ");
          int y = id.nextInt();
          int z = y-x;
          System.out.println("Exchange: "+z);
          System.out.println("Do you want to create another transaction? [Y] [N]");
          char condition = id.next().charAt(0);
          switch (condition) {
          case 'Y':
              method6();
              break;
          case 'N':
              method4();
              break;
          }
          break;
      default:
          System.out.println("Invalid function!");
          break;
       }
  </code></pre>
  
  <p>The output must be the product id, name, quantity, and amount must be displayed in different value which shared the single variable.</p>