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

Java please help, Lost on this assignment Please show OutPut, Write a program th

ID: 3827130 • Letter: J

Question

Java please help, Lost on this assignment

Please show OutPut,

Write a program that reads a Java source file and produces an index of all identifiers in the file. For each identifier, print all lines in which it occurs. For simplicity, we will consider ech string consisting only of letters, numbers, and underscores an identifer. Declare a Scanner infor reading from the source file and call in .useDeliniter("^A-Za-z0-9_]+"). Then each call to next returns an identifier.

Here's the Code i have, AirportTable:

Here's the other code, AirportTester:

Explanation / Answer

public static void main(String[] args)

{

System.out.println("Enter the path to your JAVA source file: ");

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

String pathToFile = null;

try {

pathToFile = br.readLine();

File f = new File(pathToFile);

Scanner s = new Scanner(f);

s.useDelimiter("[^A-Za-z0-9_]+");

while (s.hasNext()) {                    

String identifier = s.next();

System.out.println(identifier);

}

} catch (IOException ioe) {

System.out.println("Unable to locate file. Program will exit. "

+ ioe.toString());

System.exit(0);

}

}

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