Here are the directions: Write a program that reads words from a text file and displays all the words (duplicates allowed) in ascending alphabetical order. The words must start with a litter. The text file is passed as command-line argument (you can assume that the text file is in the same directory as the executable, i.e. bin).
Hello, this is the 4th time I asked for help and no one can explain/show me how to make run correctly this
Here are the directions: Write a program that reads words from a text file and displays all the words (duplicates allowed) in ascending alphabetical order. The words must start with a litter. The text file is passed as command-line argument (you can assume that the text file is in the same directory as the executable, i.e. bin).
I'm showing my work(code) most of the time people just change the code, but the output is the same that I have. Obviously, I'm doing something wrong on my part, specifically in the way I put my text file into the code. That's why I need someone to help me. What I'm doing wrong?
![Package Explorer X
Computer Science class
> JRE System Library [JavaSE-17]
src
(default package)
> KeywordCounter.java
> ProgramKi20.java
> Programkit.java
number.txt
test.txt
text.txt
number tvt - Computer Science class
ES:
AND 12 ▼ ▼ ▼
ProgramKi20.java Programkit.java
2 import java.util.ArrayList;
3 import java.util.Collections;
4 import java.util.Scanner;
5 public class Programki20 {
6
70
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44}
45
public static void main(String[] args) {
if (args.length != 1) {
}
System.out.println("Usage: test.txt");
System.exit(1);
String filename = args [0];
ArrayList<String> words = new ArrayList<> ();
try {
}
KeywordCounter.java
Scanner in = new Scanner (new File("C:\\Users\\kirit\\number.txt"));
while (in.hasNext ()) {
}
String word = in.next();
if (word.matches ("[a-zA-Z].*")) {
words.add (word.toLowerCase () );
}
for (String word words) {
System.out.println (word);
in.close();
Collections.sort (words);
} catch (Exception ex) {
System.err.println("Error reading file: " + ex.getMessage () );
a](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fbdc33a51-efff-4610-b226-be7150e1db8b%2F564d1be4-e855-4f1d-ab25-d1cf1de45472%2Fdavcs3e_processed.png&w=3840&q=75)
![XX
Problems @ Javadoc Declaration Console X
<terminated> ProgramKi20 [Java Application] C:\Users\kirit\.p2\pool\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_17.0.4.v20220903-1038\jre\bin\javaw.ex
Usage: test.txt](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fbdc33a51-efff-4610-b226-be7150e1db8b%2F564d1be4-e855-4f1d-ab25-d1cf1de45472%2Fj160uhb_processed.png&w=3840&q=75)

Step by step
Solved in 5 steps with 2 images









