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]
2 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]2 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
Write a sentence telling me what a town meeting might have been like
iren [92.7K]
The town meeting was interesting.
Done.
3 0
2 years ago
Read the excerpt from The Riddle of the Rosetta Stone.
Ksju [112]

Answer:

B. places a great deal of pressure on himself.

Explanation:

7 0
2 years ago
Read 2 more answers
A writer for a company headquartered in Texas is designing a 100 page report, the text ofwhich must be single-spaced to minimize
Y_Kistochka [10]

Answer:

Hi! The answer to your question would be option B.

Explanation:

The answer to your question woul be option B. Use full justification.

Full justification allows the text to be easy to read while making it look organized at the same time.

3 0
2 years ago
Each of the following is a function of a bank EXCEPT:
svetlana [45]

A. pay interest

banks make their clients pay interest, not the other way around

4 0
3 years ago
Read 2 more answers
Unlike the other courts of appeals, the Court of Appeals for the Federal Circuit _____.
Finger [1]
B. hears cases from all over the united states :)
5 0
3 years ago
Read 2 more answers
Other questions:
  • What is the national security act of 1947 reflected by
    6·1 answer
  • An experimental study is conducted examining the relationship between sleep deprivation and depression. participants are kept aw
    13·1 answer
  • A proposition is a law that is directly approved by
    12·1 answer
  • What term is used to describe a political entity located within a geographic boundary whose population shares a sense of culture
    9·1 answer
  • What is the minimum need of calorie of Nepalese citizens
    11·2 answers
  • Some people, like annemarie, are good at understanding how other people think and feel and then using this information to deal w
    11·1 answer
  • What are the two rationales for the crime of attempt?
    15·1 answer
  • Diagnoses of social anxiety disorder are a. largely constant across industrialized societies around the world. b. higher in inte
    5·1 answer
  • Which idea says that if you want to remember a piece of information, you should think about it more deeply and link it to other
    5·1 answer
  • What was one national security policy the United States established during the Corona pandemic?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!