ava Programming   This week's project involves a text file with that holds all of the novel Don Quixote*, by Miguel Cervantes. The text file has been heavily processed. It contains only lowercase letters, spaces, and new lines. That is a good format for counting words. Write code that reads through the text file one word at a time using a Scanner, and the next() method. Put the words into a HashMap, where the words are used as keys, and the values are Integers used to keep track of how many times the words occur in the text. If the text was "one fish two fish red fish blue fish one two three" then the HashMap would look like this:         key                value         "one"....        2         "fish"...        4         "two"....        2         "red"....        1         "blue"...        1         "three"..        1   Once you have created such a HashMap for the whole of the text you can write logic that prints out the answers to these questions: How many times does each of these words occur in the text: "don", "quixote", "panza", "dulcinea", "impossible", "dream" What word occurs most often in the text   COMPLETE CODE: import java.util.Iterator; import java.util.Map; import java.util.HashMap; import java.util.Arrays; class Main {   public static void main(String[] args) {     final String INPUT_FILE_NAME = "DonQuixote.txt";     // Read the file one word at a time.      // Use a HashMap to count all of the words     // Find the most common word     // Count the uses of each of these words:     //  }

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
100%

Java Programming

 

This week's project involves a text file with that holds all of the novel Don Quixote*, by Miguel Cervantes. The text file has been heavily processed. It contains only lowercase letters, spaces, and new lines. That is a good format for counting words. Write code that reads through the text file one word at a time using a Scanner, and the next() method.

Put the words into a HashMap, where the words are used as keys, and the values are Integers used to keep track of how many times the words occur in the text.

If the text was "one fish two fish red fish blue fish one two three" then the HashMap would look like this:

        key                value

        "one"....        2

        "fish"...        4

        "two"....        2

        "red"....        1

        "blue"...        1

        "three"..        1

 

Once you have created such a HashMap for the whole of the text you can write logic that prints out the answers to these questions:

How many times does each of these words occur in the text: "don", "quixote", "panza", "dulcinea", "impossible", "dream"

What word occurs most often in the text

 

COMPLETE CODE:

import java.util.Iterator;
import java.util.Map;
import java.util.HashMap;
import java.util.Arrays;

class Main {
  public static void main(String[] args) {
    final String INPUT_FILE_NAME = "DonQuixote.txt";

    // Read the file one word at a time. 
    // Use a HashMap to count all of the words
    // Find the most common word
    // Count the uses of each of these words:
    // 
}

Expert Solution
steps

Step by step

Solved in 5 steps with 3 images

Blurred answer
Knowledge Booster
Hash Table
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
  • SEE MORE 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