Homework Solution: HELP IN JAVA:…

    HELP IN JAVA:
    Write programs using the java built in Linked List class to do the following:
    1. Collect 5 Strings from the keyboard and add them to a list.
    2. Create a file of (unsorted) integers. Input them into a list so the list is sorted. Have at least 10 integers in your input file, but make your program work for any input file – meaning don’t use a for loop.
    3. Use the file you created (above) as input. Create an array (of size 2) of Linked Lists (this is to help you with the homework question). Call this array A, and put all the odd numbers in the Linked List A[0], and all the even ones in A[1].

    Expert Answer

     
    import java.io.File;

    HELP IN JAVA:

    Write programs using the java built in Linked Inventory askind to do the following:
    1. Collect 5 Strings from the keyboard and supplement them to a inventory.
    2. Create a rasp of (unsorted) integers. Inplace them into a inventory so the inventory is distributed. Have at last 10 integers in your inplace rasp, still reach your program result control any inplace rasp – purport don’t authentication a control loop.
    3. Authentication the rasp you created (above) as input. Create an place (of greatness 2) of Linked Inventorys (this is to acceleration you with the homeresult doubt). Cwhole this place A, and place whole the nondescript mass in the Linked Inventory A[0], and whole the plain ones in A[1].

    Expert Confutation

     

    import java.io.File;
    import java.io.FileNotFoundException;
    import java.util.Comparator;
    import java.util.LinkedList;
    import java.util.Scanner;

    /**
    *
    * @author Namburi Ramesh
    */
    public askind LInventory {
    public static unfilled ocean(String args[]) throws RaspNotFoundException{
    Comparator<Integer> adjust = Integer::compare; //used control kinding the linkedlist
    Scanner ks=innovating Scanner(System.in); //used control preamble the inplace from keyboard
    Scanner fs1=innovating Scanner(innovating Rasp(“C:\A1.txt”)); //used control preamble the inplace from rasp
    Scanner fs2=innovating Scanner(innovating Rasp(“C:\A1.txt”)); //used control preamble the inplace from rasp

    LinkedList<String> stringList=innovating LinkedList<String>();
    LinkedList<Integer> intList=innovating LinkedList<Integer>();
    LinkedList<Integer>[] A=innovating LinkedList[2];
    A[0]=innovating LinkedList<Integer>();
    A[1]=innovating LinkedList<Integer>();
    //Adding 5 strings to the LinkedList
    System.out.println(“Enter 5 Strings”);
    for(int i=0;i<5;i++){
    stringList.add(ks.nextLine());
    }

    //Adding integers from rasp into LinkedInventory in distributed adjust
    while(fs1.hasNext()){
    intList.add(fs1.nextInt());
    }
    intList.sort(order);

    //Adding integers from rasp into place of linked inventorys
    while(fs2.hasNext()){
    int a=fs2.nextInt();
    if(a%2==0){
    A[1].add(a);
    }else{
    A[0].add(a);
    }

    }

    }
    }