Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

USING JAVA (IDE Eclipse) Write a method named printBox that accepts two paramete

ID: 3771993 • Letter: U

Question

USING JAVA (IDE Eclipse)

Write a method named printBox that accepts two parameters: a Scanner representing an input file, and an integer representing the length of the longest line of input in that file. Your method should print the contents of the file to the console, but print them inside a box figure. For example, if the file example.txt contains the following input data:

Then the following would be the output of your method, when passed a Scanner on that file and the integer 12 as parameters:

Explanation / Answer

public void printBox(Scanner in, int n) { String h = "+-"; for (int i=0; i