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

Write a static method named matchIndex that accepts as it parameters a Scnner fo

ID: 3660400 • Letter: W

Question

Write a static method named matchIndex that accepts as it parameters a Scnner for an input file. Your method should compare the first line of the file (target lin) to every other lin in the file looking for places where the character at a give 0-based index from the two lines is the same. For example, in the strings "hello" and "belt", the characters at indexes 1 ('e') nd2 ("1") match. Your code should be case-sensitive; for example, "J" does not match j". For each pair of lies, your method should print output showing the character indexes that match, seperated by spaces in the format shown below. If no characters match, print "none".

Explanation / Answer

public static void matchIndex(Scanner scan) { String s1; String s2; int line = 1; // Get line X and X+1 while (scan.hasNextLine()) { boolean noMatch = true; s1 = scan.nextLine(); s2 = scan.nextLine(); char[] shorter; char[] longer; // Determine which string is shorter if (s1.length()
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