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
What does the European map suggest about religion in 1560?
Kruka [31]

Catholicism was still dominant in Europe.  There were many Calvinist centers in France.  Most people in Norway were Catholic.  England and Scotland had the most Muslim centers.

5 0
3 years ago
Kendra just attended a sales conference in Baltimore. She must now write a report summarizing her conference. What advice should
Marina CMI [18]

The correct answer would be option A, Begin her report by identifying the event.

Kendra just attended a sales conference in Baltimore. She must now write a report summarizing her conference. She must begin her report by identifying the event.

Explanation:

When a person is assigned to write a report about some event, the writer must remember this in mind that the readers of this report do not know about the event at all. So the writer must start the report by identifying the event.

The writer must tell about the event first, so that his reader don't get confused about the report and read it smoothly. Then he should move towards the summary of the whole events by cover every important topic discussed in that event. He should also highlight the main points using the paragraphing and bullets.

Learn more about writing a report at:

brainly.com/question/13551324

#LearnWithBrainly

6 0
4 years ago
The single factor that most distinguishes female prisoners from their male counterparts is:
rusak2 [61]
The single factor that most distinguishes female prisoners from their male counterparts is: sexual abuse.
3 0
3 years ago
Someone please help me with the second questions, im not sure which one is the correct answer
Effectus [21]

Answer:

The correct answer is vigilantes.

Explanation:

Vigilantes Of California - Legends of Americahttps://www.legendsofamerica.com › california-vigilantes

8 0
2 years ago
What comes to mind when you hear the word “freedom”?
Georgia [21]

Answer:

when it come freedom in my mind i feel like free

Explanation:

6 0
3 years ago
Read 2 more answers
Other questions:
  • Marsha says, "There is no way I am going to school today with this bruise on my cheek. Everybody is going to laugh at me." Marsh
    7·1 answer
  • Which step in the research process must be completed before a research question is written
    11·1 answer
  • Ella was an aggressive child in middle school. In high school, she is a successful three-sport athlete because she channels her
    15·1 answer
  • What was the most common reason in which ancient people chose to
    5·1 answer
  • Help me Plzzzzzzzzzzzzzzzzzzzzzzzzzzz
    11·2 answers
  • What is the brain system that allows conscious control over motor actions?​
    14·1 answer
  • Why did so many early civilizations arise near river valleys?
    7·1 answer
  • Please give me an real answer and don't just take my points or just saying that you need them or just saying random thing please
    8·2 answers
  • Which country has a shorter coastline microsoft rewards.
    15·1 answer
  • American neutrality was tested when this county was attacked in the 1930s? philippines guam russia china
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!