1. Create a new Java class in a file named Practice01.java and define a static function...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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. 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.
Expert Answer:
Answer rating: 100% (QA)
1The Practice01 class has been implemented using the arrayToString function in accordance with your specifications public class Practice01 public stat... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
A regular language is a language that can be defined by a regular expression. 0 2 . 1 Complete the unshaded cells of Table 1 to show which of the statements about regular languages are true and which...
-
A driver of a car is initially 455 miles from home, traveling toward home on a straight freeway at 70 miles per hour. (a) Write a formula for a linear function f that models the distance between the...
-
What does a decibel measure?
-
Affected by the instability of oil prices, the value of a business personal property (BPP) of an oil-based ink manufacturer fluctuates constantly. The manufacturer has subscribed a property insurance...
-
How might a hacker access and manipulate a digital device for illegal purposes? Are the Internet of Things (IoT) devices at risk for hacker access and manipulation?
-
Nadal Inc. has two temporary differences at the end of 2008. The first difference stems from installment sales, and the second one results from the accrual of a loss contingency. Nadals accounting...
-
A uniform plane wave (free space wave number ko = 2/o = /c) impinges on a boundary between two media at an incident angle 1 as shown below. Wave vectors are in black, wave fronts are in red. Given...
-
Claude Lopez is the president of Zebra Antiques. His employee, Dwight Francis, is due a raise. Dwight?s current benefits analysis is as follows: Company Cost (Current) Yearly Benefit Costs Employee...
-
Could you analyze the role of avant-garde artistic movements in subverting normative socio-cultural paradigms, thereby engendering a paradigm shift in the collective consciousness and fostering...
-
Calculate the current economic value of an annuity that will pay Marzook $4000 at the beginning of every six months for the next 7 years and then $6000 at the beginning of every six months for the...
-
Anthony, a single taxpayer, purchased a house on January 1, 2017 that he held as an investment until December 31, 2019. He converted the property to be his principal residence beginning January 1,...
-
Ignoring energy losses due to friction, and taking the density of water to be 1000 kg/m, consider the following two cases: (a) Water flows in a tapered pipe at a rate of 1400 L/min from Point A with...
-
On March 28, 20x1, TP acquired a three story building, The first floor has a restaurant, and the 2nd and 3rd floor is rented to small start-up companies. TP paid $12MM for the property, with $2MM of...
-
You own a broker business named XYZ Brokers and employ five staff two additional brokers and three staff in support roles. Your support staff assist both you and your additional two brokers in...
-
Watch the video in the link below and answer the questions: https://www.youtube.com/watch?v=I8_gmYNCQ1g What is Zaras product strategy? How did Zara take over the industry using fast fashion?
-
How is use of the word consistent helpful in fraud reports?
-
If you fail to close an output file, ____________. A. There are usually no serious consequences B. You might lose access to the written data C. Java will close it for you automatically D. Two of the...
-
A class that will respond to button-press events must use which phrase in its header? a. Import java.event b. Extends action c. Extends j frame d. Implements action listener
-
Modify the AnimationinJavaFX application created in the You Do It exercise to add a triangle and have it follow a path. Also, have the object change colors from yellow to green. Save the project as...
-
Figure P2.4 shows a graph of position versus frame number from a video clip of a moving object. Describe this motion from beginning to end, and state any assumptions you make. Data from Figure P2.4...
-
What minimum information must be extracted from a video clip of a moving object in order to quantify the object's motion?
-
The sequence in Figure P2.3 represents a ball that is initially held above the ground. In the first frame the ball is released. In subsequent frames the ball falls, bounces on the ground, rises, and...
Study smarter with the SolutionInn App