1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
ivanzaharov [21]
3 years ago
10

(Count the occurrences of words in a text file) Rewrite Listing 21.9 to read the text from a text file. The text file is passed

as a command-line argument. Words are delimited by whitespace characters, punctuation marks (, ; . : ?), quotation marks (' "), and parentheses. Count the words in a case-sensitive fashion (e.g., consider Good and good to be the same word). The words must start with a letter. Display the output of words in alphabetical order, with each word preceded by the number of times it occurs.
I ran my version of the program solution on its own Java source file to produce the following sample output:
C:\Users\......\Desktop>java CountOccurrenceOfWords CountOccurrenceOfWords.java
Display words and their count in ascending order of the words
1 a
1 alphabetical
1 an
2 and
3 args
2 as
1 ascending
1 catch
1 class
4 count
2 countoccurrenceofwords
1 create
1 display
1 else
3 entry
3 entryset
2 ex
1 exception
1 exit
1 file
2 filename
3 for
1 fullfilename
3 get
1 getkey
1 getvalue
1 hasnext
1 hold
5 i
3 if
2 import
2 in
3 input
2 int
1 io
3 java
6 key
3 length
2 line
1 main
3 map
1 matches
3 new
1 nextline
1 null
1 of
2 order
3 out
3 println
1 printstacktrace
2 public
2 put
2 scanner
1 set
1 split
1 static
5 string
4 system
2 the
1 their
1 to
1 tolowercase
2 tree
6 treemap
2 trim
1 try
1 util
1 value
1 void
1 while
9 words
C:\Users\......\Desktop>
Computers and Technology
1 answer:
Oksanka [162]3 years ago
3 0

Answer:

Explanation:

The following is written in Java. It uses File input, to get the file and read every line in the file. It adds all the lines into a variable called fullString. Then it uses regex to split the string into separate words. Finally, it maps the words into an array that counts all the words and how many times they appear. A test case has been created and the output can be seen in the attached image below. Due to technical difficulties I have added the code as a txt file below.

You might be interested in
There are types of templates​
guajiro [1.7K]
You didn’t explain your question correctly so I can’t help you
3 0
2 years ago
Typing with capital letters and exclamation points in an e-mail is an example of
Aleks [24]
It's an example of a poorly written email, it looks like somebody is angry and yelling at you, these types of emails can be described as a poor etiquette.
3 0
3 years ago
Read 2 more answers
Initialize the tuple team_names with the strings 'Rockets', 'Raptors', 'Warriors', and 'Celtics' (The top-4 2018 NBA teams at th
dexar [7]

Answer:

Following is the code in python language

team_names = ('Rockets','Raptors','Warriors','Celtics')#holding the string value

print(team_names[0],team_names[1],team_names[2],team_names[3])#display

Output:

Rockets Raptors Warriors Celtics

Explanation:

Following is the description of above statement .

  • Create a dictionary "team_names" that is holding the string value Rockets Raptors Warriors and Celtics.
  • Finally we used the print function in that function we pass the index of corresponding dictionary i.e team_names[0] . it will display the first index value  similarly we pass  team_names[1], team_names[2]  team_names[3].
8 0
2 years ago
What is the next line?
Evgen [1.6K]

Answer:3

Explanation: it’s 3

3 0
3 years ago
Read 2 more answers
Convert 30 to hexadecimal ​
Delvig [45]

Answer:

1E

Explanation:

Here is a table to help you. Similar to a multipication table, just follow either the number 3 down to A (aka 10) or 6 x 5 and you will find your answer of

1E = 30

6 0
3 years ago
Other questions:
  • Why is brainly not working it say im logged out rn but im not i cant acces anything but this
    12·2 answers
  • What is the maximum upload speed you can get on an isdl internet connection?
    9·1 answer
  • What is the safest way to install a new flash drive
    7·2 answers
  • Write JavaScript code to declare a variable of the name favoriteColor
    13·1 answer
  • The graph shows households in the world with internet access from 2003 to 2019. A graph titled Percentage of Households with Int
    6·2 answers
  • Please help this is a coding assignment I need help! (use python)
    12·1 answer
  • Please please help I don’t understand this
    6·1 answer
  • What is data intergrity​
    13·1 answer
  • What is the complete path and filename of the file where ports and their associated protocols are defined
    12·1 answer
  • I'm not sure how to solve this problem
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!