title: Adding multiple items using linkedlist, JAVA
body: <blockquote>
    <p>This is the Question:</p>
  </blockquote>
  
  <p>Assume that card has a valid PIN to start, and that there is 100 units in the bank account.
  Each video has a rental ‘cost’. You will need to scan the Basket list and calculate the total for the ATM transaction. You can assume there is always enough units in the bank account to cover the cost of the rental for this exercise.
  A version of Video Kiosk code will contain the following steps:</p>
  
  <p>• Create Linked List for Video Titles and fill with choice of 5 items</p>
  
  <p>• Create an empty Linked List (Basket) to store the customer selection</p>
  
  <p>• Present a menu driven selection process</p>
  
  <ul>
  <li>Display on screen itemized with a selection number</li>
  <li>Identify the selection and determine if it is valid</li>
  <li>Put selected video into 2nd linked list (Basket)</li>
  <li>Remove the previously selected video from the available Title list </li>
  <li><p>Complete selection process</p>
  
  <blockquote>
    <blockquote>
      <p>Bring the contents of the basket list to the ATM and pay</p>
    </blockquote>
  </blockquote></li>
  </ul>
  
  <p>Vkiosk.java</p>
  
  <pre><code>    import java.util.Iterator;
      import java.util.LinkedList;
      import java.util.Scanner;
  
      public class VKiosk {
          private static LinkedList VTable=new LinkedList();
          private static LinkedList Basket=new LinkedList();
          private static double rentCost=0;
          private static int j=1;
          /**
           * @param args the command line arguments
           */
          public static void main(String[] args) {
               // declaring scanner name as "typeNumber"
          Scanner typeNumber = new Scanner(System.in);    
          System.out.println("::: Welcome to My Java Program To model an ATM machine :::");
  
              showVideoList();
              System.out.print("Input the serial number of video to buy: ");
              buyVideo();
              System.out.println("Your total amount of Cost: "+ rentCost);
  
              MMachine buy = new MMachine();
              buy.Txn(rentCost);
  
  
  
          }
          public static double buyVideo(){
              Scanner typeNumber = new Scanner(System.in);
              String title=typeNumber.nextLine();
              String amount=null;
              for(int i=0;i&lt;VTable.size();i++){
                  String videoDetails=VTable.get(i).toString();
  
                  if(videoDetails.toLowerCase().contains(title.toLowerCase())){
                      Basket.add(VTable.get(i));
                     for(int j=videoDetails.length()-2;j&gt;=0;j--){
                         if(videoDetails.charAt(j)==' '){
                          break;
                         }
                          amount=videoDetails.substring(j, videoDetails.length()-1);
  
                     }
                      VTable.remove(i);
                  }
  
              }
              rentCost=Double.parseDouble(amount);
  
              return rentCost;
          }
  
  
          public static void VideoList(){
             Video vTable1=new Video("BladeRunner", 1, 5);
             Video vTable2=new Video("Wages of Fear", 2, 4);
             Video vTable3=new Video("Grease", 3, 5);
             Video vTable4=new Video("Mama Mia", 4, 4);
             Video vTable5=new Video("L'Illusionniste", 5, 6);
             VTable.add(vTable1);
             VTable.add(vTable2);
             VTable.add(vTable3);
             VTable.add(vTable4);
             VTable.add(vTable5);
          }
          public static void showVideoList(){
                  System.out.println();
                  System.out.println("********************************************************************");
                  System.out.println("List of the Videos are: ");
                  System.out.println("********************************************************************");
                  System.out.println("Serial No       Video Detetails");
                  VideoList();
  
                  for(int i=0; i&lt;VTable.size(); i++){
                      System.out.println( j+"               "+VTable.get(i));
                      j++;
                  }
                  System.out.println();
          }
  
  
      }
  </code></pre>
  
  <p>Video.java</p>
  
  <pre><code>public class Video{
      private String  title;
      private int     serial;
      private double  cost;
  
      public Video(String title, int serial, double cost)
      {
          this.title  = title;
          this.serial = serial;
          this.cost   = cost;
      }
  
      public String getTitle()  {return title;}
      public int    getSerial() {return serial;}
      public double  getCost()   {return cost;}
  
  
      public String getVideo() {
      return "title:" + title + " Serial: " + serial + " Cost: " + cost;
    }
      //  Upgrade output of toString ()
  
      @Override
      public String toString() {
          return "["+getVideo()+"]";
    }
  }
  </code></pre>
  
  <p>I am succeed to buy only one items, need to buy multiple items through Linked List Basket.</p>