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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!