Question: Section C: Programming [20 marks] All answers must be written in valid Java code. Though you are not obligated to provide comments in your code,
Section C: Programming [20 marks]
All answers must be written in valid Java code. Though you are not obligated to provide comments in your code, all other Programming Standards must be observed. You may choose to first write your solution in an IDE, and then copy/paste it into the space provided below - ensure that your code is properly indented if you do.
Do not use any built-in Java classes unless they were covered in the online course notes, or if the question specifically says otherwise. For example, you are permitted to use ArrayList, String and Exceptions.
Question 26 (10 points)
![Section C: Programming [20 marks] All answers must be written in valid](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3b951a6248_72166f3b9518693c.jpg)
Provide the code for a static findWordsBeside method in the text-box below. This method must accept two String arguments: searchWord and fileName, and return nothing. The argument searchWord is a word that is to be searched for in a file named fileName. For each occurrence of searchWord in the file, print to screen the words that appear beside it. For the purposes of this question, a word is defined as a set of contiguous characters delimited by whitespace. Note that words appearing on different file lines are never considered to be beside each other. You must also handle exceptions (by simply printing out their message) where necessary.
For example, a file containing the lines:
four score and seven years ago our fathers brought forth on this continent a new nation, conceived in liberty, and dedicated to the proposition that all men are created equal
and run with the search word "and" would produce the following output:
score seven dedicated
You can assume that java.io.* has been imported into your code file.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
