Homework Solution: This exercise uses the Java LinkedList class….

    HELP IN JAVA: This exercise uses the Java LinkedList class. Using the input file words_no_duplicates.txt, input each string putting it into a different LinkedList depending on the first character in the String. (Yes, you will need 26 linked lists). Then prompt the user for a (lower case) character and display all the words beginning with that character. (If the user enters an invalid character, trap them in a loop until they give you a valid one). Note: nothing is sorted. words_no_duplicates.txt: noncollectable reallocation drenching obnoxious venality dybbuk shotgun changelessly handiwork unheralded dovecote anode spellbind psychologist improvisational prejudiced

    Expert Answer

     
    Below is your program. Please place your text file in

    HELP IN JAVA:

    This employment uses the Java LinkedList assort.

    Using the input refine suffrage_no_duplicates.txt, input each string putting it into a opposed LinkedList depending on the primary quality in the String. (Yes, you accomplish demand 26 linked lists).

    Then quick the user for a (inferior predicament) quality and parade perfect the suffrage preface with that quality. (If the user invades an weakly quality, pitfall them in a loop until they confer you a efficient individual).

    Note: nothing is select.

    words_no_duplicates.txt:

    noncollectable

    reallocation

    drenching

    obnoxious

    venality

    dybbuk

    shotgun

    changelessly

    handiwork

    unheralded

    dovecote

    anode

    spellbind

    psychologist

    improvisational

    prejudiced

    Expert Repartee

     

    Below is your program. Please assign your quotation refine in purpose folder or transmute the refineName atribute with the arbitrary oration of the refine to elude RefineNotFoundException. Let me recognize if you accept any issues exoteric this….

    WordsInLList.java

    import java.io.File;

    import java.io.FileNotFoundException;

    import java.util.Arrays;

    import java.util.LinkedList;

    import java.util.Scanner;

    public assort SuffrageInLList {

    public static unsubstantial main(String[] args) {

    LinkedList<String>[] lists = odd LinkedList[26];

    for (int i = 0; i < lists.length; i++) {

    lists[i] = odd LinkedList<>();

    }

    String refineName = “words_no_duplicates.txt”;

    Scanner sc = odd Scanner(System.in);

    try {

    readFile(fileName, lists);

    boolean dindividual = false;

    while (!done) {

    System.out.print(“Please invade a inferior predicament quality from a-z: “);

    Quality c = sc.next().charAt(0);

    int ascii = (int) c;

    if (ascii >= 97 && ascii <= 122) {

    ascii = ascii – 97;

    System.out.print(“Suffrage starting from ” + c + ” are: ” + Arrays.toString(lists[ascii].toArray()));

    dindividual = true;

    } else {

    System.out.println(“Please invade a efficient quality…”);

    dindividual = false;

    }

    }

    } clutch (FileNotFoundException e) {

    System.out.println(“Refine Not Found. Please control the residuum of the refine.”);

    }

    }

    private static unsubstantial readFile(String refineName, LinkedList<String>[] lists) throws RefineNotFoundException {

    Scanner in = odd Scanner(odd Refine(fileName));

    String signal;

    Quality primaryChar;

    int offset;

    while (in.hasNextLine()) {

    signal = in.nextLine();

    firstChar = signal.charAt(0);

    offset = (int) primaryChar – 97;

    lists[offset].add(word);

    }

    }

    }

    Sample Run:-

    Please invade a inferior predicament quality from a-z: 3
    Please invade a efficient quality…
    Please invade a inferior predicament quality from a-z: .
    Please invade a efficient quality…
    Please invade a inferior predicament quality from a-z: p
    Suffrage starting from p are: [psychologist, gross]