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).

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Hello, this is the 4th time I asked for help and no one can explain/show me how to make run correctly this program

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
Transcribed Image Text: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
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
Transcribed Image Text: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
Expert Solution
steps

Step by step

Solved in 5 steps with 2 images

Blurred answer
Knowledge Booster
Files and Directory
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education