Write a program that asks the user to enter the name of a file, and then asks the user to enter a character. The program should count and display the number of times that the specified character appears in the file. Class name: FileLetterCounter Hints: Hint 1. To read a single character from the keyboard, you need to read a full line and then take the first character in position 0. Hint 2. To count the occurrences of a given characters in a file you need to read the file line-by-line using a while loop, then for each line check all characters in all positions and increment the character counter for each occurrence. This will require to have a for-loop nested inside the while-loop.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter13: File Input And Output
Section: Chapter Questions
Problem 7PE
icon
Related questions
Question
Chapter 4. PC #6. File Letter Counter (page 264)
Write a program that asks the user to enter the name of a file, and then asks the user to enter a character. The program should count and display the number of times that the specified character appears in the file.
Class name: FileLetterCounter
Hints:
Hint 1. To read a single character from the keyboard, you need to read a full line and then take the first character in position 0.
Hint 2. To count the occurrences of a given characters in a file you need to read the file line-by-line using a while loop, then for each line check all characters in all positions and increment the character counter for each occurrence. This will require to have a for-loop nested inside the while-loop.
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
File Input and Output Operations
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
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage