1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
boyakko [2]
3 years ago
14

Write a method named matchIndex that accepts as its parameter a Scanner for an input file. Your method should compare each neigh

boring pair of lines (the first and second lines, then the third and fourth lines, and so on) looking for places where the character at a given 0-based index from the two lines is the same. For example, in the strings "hello" and "belt", the characters at indexes 1 ('e') and 2 ('l') match. Your code should be case-sensitive; for example, "J" does not match "j".
Social Studies
1 answer:
sp2606 [1]3 years ago
3 0

Answer:

Java code given below

Explanation:

Java code:

import java.util.*;

import java.io.*;

import java.math.*;

public class abc {

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

File file = new File("input.txt");

Scanner sc = new Scanner(file);

matchIndex(sc);

}

public static void matchIndex(Scanner sc){

int line=1;

while(sc.hasNextLine()){

System.out.print( "lines "+Integer.toString(line)+" and "+Integer.toString(line+1)+": ");

String s=sc.nextLine();

String t=sc.nextLine();

s=s.trim();

t=t.trim();

int l=Math.min(s.length(),t.length());

Boolean match=false;

for(int i=0;i<l;i++){

if(s.charAt(i)==t.charAt(i)){

System.out.print(Integer.toString(i)+" ");

match=true;

}

}

if(!match){

System.out.println("none ");

}

else{

System.out.println();

}

line=line+2;

}

}

}

You might be interested in
Critical sociology can best be described as a(n) ________ approach.
kati45 [8]
The activist approach
8 0
3 years ago
During World War II, the United States government was forced to ration consumer goods like gasoline, tires, sugar, and coffee. W
spin [16.1K]
I could be wrong but i think its D
8 0
3 years ago
It is the supreme court’s responsibility to monitor government infringement on civil rights according to the doctrine of:
ch4aika [34]
It is the supreme court’s responsibility to monitor government infringement on civil rights according to the doctrine of Judicial review.
3 0
3 years ago
Do different theories of the human person lead to different conclusions in the following
nikdorinn [45]

Yes, some theories of the human person are against capital punishment such as the school of thought of Aristotle.

<h3>What is Capital Punishment?</h3>

This refers to the legally authorized killing of a person based on his capital crimes which usually involve the murder of another person or group of persons.

Hence, it is worth noting that while murder is widely condemned, there are some people like Aristotle who are against capital punishment as he believes that is not morally permissible.

Read more about capital punishment here:
brainly.com/question/7229220

8 0
2 years ago
What are personality researchers particularly interested in studying?
kogti [31]
The human brain i believe
8 0
3 years ago
Other questions:
  • How do i do the south america project
    8·1 answer
  • During the Vietnam War, what voting rights were changed by the 26th Amendment? A. It lowered the voting age from 21 to 18 so tho
    14·2 answers
  • What was farming like in the 1920s? <br> Please answer with your own words, no plagiarizing, thanks.
    8·1 answer
  • Read this excerpt from the dissenting opinion in a supreme court case.if a white man and a black man choose to occupy the same p
    11·2 answers
  • Janet often encounters john at school. because of this, they end up becoming friends. this scenario illustrates how ____________
    13·1 answer
  • Professor Boyd suggests that children in every culture can distinguish between costs and benefits because humans have an inborn
    7·1 answer
  • Helppp plssssss!!! <br><br>Thanks!
    13·1 answer
  • Did the Utah and New Mexico want to be a free state? Did the south loose to all the possible things they could have gotten in th
    12·1 answer
  • After the Boston Tea Party, the British<br> Parliament and the King did which of the<br> following?
    13·2 answers
  • Which of the following did Hatshepsut not do? (1 point)
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!