Answered step by step
Verified Expert Solution
Question
00
1 Approved Answer
1. (Filestats.java) Write a program that prompts the user to enter a filename (use a Scanner to get the filename). The program then outputs to
1. (Filestats.java) Write a program that prompts the user to enter a filename (use a Scanner to get the filename). The program then outputs to the screen the number of lines, words and characters in the file C:Userslaaron\Desktop>java FileStats Enter input file name: textl.txt 32 lines 159 words 810 characters. Once you have that working, make the following changes. Collect the filename using a JFileChooser instead of using a Scanner. (Not shown here.) Also prompt the user to enter a string to search for in the file. In your output, state how many lines contained the requested string and display the lines and their line number C:\Users\aaron\Desktop>java FileStats Enter input file name: textl.txt Enter a string to search for and 33 lines 159 words 810 characters. Your requested word -and - was found 8 times. 6: And what to do and how to be 10: But there in the sandpile at Sunday school. 21: Wash your hands before you eat. 23: Warm cookies and cold milk are good for you. 25: Learn some and think some 26 And draw and paint and sing and dance 27 And play and work everyday some. 31: Hold hands and stick together
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started