Please use JAVA code to write the solution, thanks  A text file called names.txt contains one name per line, e.g., Allison John William John etc. Names can be duplicated in the file. Write the code that: 1.      Reads the names line by line. 2.      Stores each name and the number of times the name appears in one collection. 3.    Prints the number of different names to the console. 4.      Prints the names and how many times each name appears on the console. Think about what data structure would work in associating each name with the number of times it appears in the file. You do not need to write imports.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question

Please use JAVA code to write the solution, thanks 

A text file called names.txt contains one name per line, e.g.,
Allison
John
William
John
etc.
Names can be duplicated in the file. Write the code that:
1.      Reads the names line by line.
2.      Stores each name and the number of times the name appears in one collection.
3.    Prints the number of different names to the console.
4.      Prints the names and how many times each name appears on the console.
Think about what data structure would work in associating each name with the number of times it appears in the file. You do not need to write imports.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Constants and Variables
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
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT