Home / Expert Answers / Computer Science / create-a-method-that-have-nbsp-2-parameters-a-filename-and-a-lowercase-letter-1-print-all-the-l-pa366

(Solved): Create a method that have  2 parameters : a filename and a lowercase letter. 1) print all the l ...



Create a method that have  2 parameters : a filename and a lowercase letter.

1) print all the lines in the file that start with the uppercase or lowercase letter. Use str.toLowerCase() to get string that converted all the letter to lowercase( Example: the letter 'b' would match the line starting with "Boy" or "back".

2)Return the number of lines that you have printed

3)Printing a message if any exceptions occur

4)Create a main method to the class to test the function. ( copy paste any paragraph to a txt file to test the method)

 



We have an Answer from Expert

View Expert Answer

Expert Answer


Solution: import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class Main { public static void main(String[] args) { String filename = "text.txt"; char letter = 'b'; int count = printLinesWithLetter(filename, le
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe