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
When you're working with a word processing document and you press the DEL Key what happens
wariber [46]
<span>The character to the right of the cursor is deleted. </span>
4 0
3 years ago
Read 2 more answers
WAP to print given series by using sub procedure 2,3,5,8,13,...........,20th term.​
Alex17521 [72]

Answer: c++

int fibonacci(int n) {

if (n < 0) {

return -1;

} else if (n == 0 || n == 1) {

return n;

} else {

return fibonacci(n - 1) + fibonacci(n - 2);

}

}

int main() {

int i;

for (i = 0; i < 20; i++) {

cout << fibonacci(i) << " ";

}

}

Explanation:

this is fibonacci

7 0
3 years ago
An employee was watching Jessica, an IT employee, typing in many different confusing terms. Jessica explained that she needed to
zzz [600]

Answer:

Programming and Software Development

Explanation:

8 0
3 years ago
Read 2 more answers
░▒▓█►─═ ℍᵒ ═─◄█▓▒░ (っ◔◡◔)っ ♥ how are you doing ♥
Lera25 [3.4K]
I’m not doing too hot
Stressing over school and I doesn’t help that I don’t understand somethings
8 0
3 years ago
A program that helps computer users do specific things like word processing, etc., e-mailing, or browsing the Internet
Dimas [21]

This is an application

6 0
4 years ago
Other questions:
  • Select the correct answer.
    8·1 answer
  • Desirable workplace habits and skills include:
    6·2 answers
  • How to construct a speaking library presentation database. How will you use this library and database in the furture? Based on w
    10·1 answer
  • The __________ format is a proprietary file format defined by guidance software for use in its forensic tool to store hard drive
    15·1 answer
  • (15 POINTS) Integrated Circuits Of Made Up Of _____ That Carry The Electrical Current.
    10·1 answer
  • 2. Choose all of the correct answers for each of the following: [a] The relations of two sub-entity sets of the same super entit
    6·1 answer
  • I don't want my large video files using up all my hard drive space . Can I archive my videos in on DVDs or Blu Rays?
    8·1 answer
  • Power point is hardware or software​
    12·2 answers
  • A manager suspects that one of his team members has been fraudulently accessing confidential and sensitive information and breac
    8·2 answers
  • Machine language is the set of binary-coded instructions that are executed directly by a computer. True or false
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!