Question
3. Define a method named printLines that declares parameters for a filename and a lowercase letter. The method should do the following: a. Print all
3. Define a method named "printLines" that declares parameters for a filename and a lowercase letter. The method should do the following: a. Print all of the lines in the file that start with the specified letter (uppercase or lowercase). For example, the letter 'y' would match a line starting with "You" or "yet". Hint: you can use str.toLowerCase() to get a copy of str with all of the letters converted to lowercase. b. Return the number of lines that were printed. c. Handle any exceptions that occur by printing a message. Add a main method to the class to test your printLines function with the provided alice.txt file and the letter(s) of your choice. The expected counts for some letters are shown below.
a 262 b 76 c 89 x 0 y 37 z 0
alice.txt link file
https://drive.google.com/file/d/1P6_h5CMeKDXFK76uVPToFlo_nYvFSjiA/view?usp=share_link
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored 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