Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

What I have so far:

public class H {

public static void main(String[] args) { //LinkedList Strings A-Z /*LinkedList a = new LinkedList(); LinkedList b = new LinkedList(); LinkedList c = new LinkedList(); LinkedList d = new LinkedList(); LinkedList e = new LinkedList(); LinkedList f = new LinkedList(); LinkedList g = new LinkedList(); LinkedList h = new LinkedList(); LinkedList i = new LinkedList(); LinkedList j = new LinkedList(); LinkedList k = new LinkedList(); LinkedList l = new LinkedList(); LinkedList m = new LinkedList(); LinkedList n = new LinkedList(); LinkedList o = new LinkedList(); LinkedList p = new LinkedList(); LinkedList q = new LinkedList(); LinkedList r = new LinkedList(); LinkedList s = new LinkedList(); LinkedList t = new LinkedList(); LinkedList u = new LinkedList(); LinkedList v = new LinkedList(); LinkedList w = new LinkedList(); LinkedList x = new LinkedList(); LinkedList y = new LinkedList(); LinkedList z = new LinkedList(); */ LinkedList[] lists = new LinkedList[26]; for (int i = 0; i < lists.length; i++) { lists[i] = new LinkedList<>(); //Input File Scanner fileInput = null; //Try Catch File inFile = new File("words_no_duplicates.txt"); //try/catch try { fileInput = new Scanner(inFile); } catch (FileNotFoundException ex) { } //Add to list String letter = " "; //While Loop while (fileInput.hasNext()) { letter = fileInput.next(); if (!(letter.contains(letter))) { letter.add(letter); } } //Scanner Scanner scnr = new Scanner(System.in); //Prompt user for Input System.out.println("Enter a lowercase letter: "); String chara = scnr.next(); LinkedList list = letter.add(chara);

//else { System.out.print("Word starts with entered character not found."); } } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems Uropean Conference Adbis 2020 Lyon France August 25 27 2020 Proceedings Lncs 12245

Authors: Jerome Darmont ,Boris Novikov ,Robert Wrembel

1st Edition

3030548317, 978-3030548315

More Books

Students also viewed these Databases questions