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

Modify the program to read the people.txt file line by line using nextLine(). Pr

ID: 3691330 • Letter: M

Question

Modify the program to read the people.txt file line by line using nextLine(). Print each line between angle bracks <...>. Your output should look like this:

<75 Fresco, Al>
<67 Dwyer, Barb>
<55 Turner, Paige>
<108 Peace, Warren>
<46 Richman, Mary A.>

people.txt file

75 Fresco, Al
67 Dwyer, Barb
55 Turner, Paige
108 Peace, Warren
46 Richman, Mary A.
37 Ware, Crystal
83 Carr, Dusty
15 Sledd, Bob
64 Sutton, Oliver
70 Mellow, Marsha
29 Case, Justin
35 Time, Justin
8 Shorts, Jim
20 Morris, Hugh
25 Vader, Ella
76 Bird, Earl E.

This is the code that needs to be modified to get the output stated above, thanks! *working in eclipse

import java.io.*;

import java.util.*;

public class CountWords {

public static void main(String[] args) throws FileNotFoundException {

Scanner input = new Scanner(new File("people.txt"));

  

  

}

System.out.println();

}

}

Explanation / Answer

import java.io.*;
import java.util.*;

public class CountWords {
public static void main(String[] args) throws FileNotFoundException {
Scanner input = new Scanner(new File("people.txt"));
       
       while (input.hasNextLine())
           {
String line = input.nextLine();
System.out.println("<" + line + ">");   
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote