Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. Create a new Java class in a file named Practice01.java and define a static function named arrayToString that declares a parameter for an
1. Create a new Java class in a file named "Practice01.java" and define a static function named "arrayToString" that declares a parameter for an int array and returns a string. Your function should translate the array into a string in the format "[1, 2, 3]" (do not use the Arrays.toString() method to do it for you). 2. Create a JUnit unit test for your Practice01 class. Write at least two tests to verify that your arrayToString function is working properly. 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 are shown in the table below. a 262 62 g 50 E b 76 h 99 n 47 12 47 169 y 37 42 t 361 Z 0 C 89 i 92 0 93 U 20 d 57 j 11 P 60 v 13 e f 36 k 20 15 W 123 67 1 68 L 51 x 0.
Step by Step Solution
★★★★★
3.47 Rating (160 Votes )
There are 3 Steps involved in it
Step: 1
1The Practice01 class has been implemented using the arrayToString function in accordance with your specifications public class Practice01 public stat...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