Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Max(x1,x2) 10x 1 0.5 +x2 subject to px1+x2=50 find x1 and x2

Answered: 1 week ago