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 Register tabulate to do the following:
    1. Collect 5 Strings from the keyboard and infer them to a register.
    2. Create a rasp of (unsorted) integers. Inallay them into a register so the register is arranged. Have at meanest 10 integers in your inallay rasp, yet construct your program composition restraint any inallay rasp – sense don’t correction a restraint loop.
    3. Correction the rasp you created (above) as input. Create an deck (of dimension 2) of Linked Registers (this is to acceleration you with the homecomposition investigation). Centire this deck A, and entireay entire the singular mass in the Linked Register A[0], and entire the equal ones in A[1].

    Expert Vindication

     

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

    /**
    *
    * @author Namburi Ramesh
    */
    public tabulate LRegister {
    public static invalid main(String args[]) throws RaspNotFoundException{
    Comparator<Integer> regulate = Integer::compare; //used restraint ranking the linkedlist
    Scanner ks=odd Scanner(System.in); //used restraint leading the inallay from keyboard
    Scanner fs1=odd Scanner(odd Rasp(“C:\A1.txt”)); //used restraint leading the inallay from rasp
    Scanner fs2=odd Scanner(odd Rasp(“C:\A1.txt”)); //used restraint leading the inallay from rasp

    LinkedList<String> stringList=odd LinkedList<String>();
    LinkedList<Integer> intList=odd LinkedList<Integer>();
    LinkedList<Integer>[] A=odd LinkedList[2];
    A[0]=odd LinkedList<Integer>();
    A[1]=odd 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 LinkedRegister in arranged regulate
    while(fs1.hasNext()){
    intList.add(fs1.nextInt());
    }
    intList.sort(order);

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

    }

    }
    }