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
Making the correct adjustments in the money supply can be difficult because each action by the Fed has a ___________ effect as w
larisa86 [58]

Answer:

lag

Explanation:

Making the correct adjustments in the money supply can be difficult because each action by the Fed has a lag  effect as well as an interactive impact on the variables that the Fed is trying to control..

8 0
4 years ago
Which of the following was the origin of today's marathons?
Andreas93 [3]

Answer:

Option 2

Explanation:

5 0
3 years ago
Jim watches lots of violent television while Sam prefers to watch comedies. As the boys walk to school one day, they witness one
Harrizon [31]

The correct answer would be, Jim will not react at all, Sam may intervene.

As the boys walk to school one day, they witness one of their classmates being bullied by an older child. According to research on desensitization effect, Jim will not react at all, Sam may intervene.

Explanation:

Desensitization is a concept in psychology. It is a process in which the emotional responsiveness to a negative or positive stimulus diminishes, after it is being exposed to it repeatedly.

In simple words, when something begins to happen repeatedly, the emotional responsiveness towards that diminishes gradually.

So because Jim is used to watch movies full of violence and concerned things, and Sam was not used to such things, then according to desensitization, Jim will not react at all because he was exposed to such stimulus repeatedly, but Sam might intervene as this would be a new situation for him.

Learn more about Desensitization at:

brainly.com/question/4189372

#LearnWithBrainly

4 0
3 years ago
Why do you think brainstorming is helpful when solving a problem?
AleksAgata [21]
I think brainstorming is helpful when solving a problem because it helps to get all of your ideas out and then you can choose the best one.
5 0
3 years ago
He was a french philosopher who developed a number of political theories in his spirit of the laws. Who is this philosopher?
Alja [10]

Answer:

John locke

Explanation:

google it and it said that

8 0
3 years ago
Read 2 more answers
Other questions:
  • According to milgram's (1970) ________ hypothesis, compared to rural dwellers, people in large cities are bombarded with stimula
    10·1 answer
  • How did the Federalists promote the Constitution to the American public? Question options: They went door-to-door asking people
    14·2 answers
  • What are Non-governmental organisations?
    15·1 answer
  • Which of the following is the best example of a random assignment in an experiment?
    15·1 answer
  • Citizens of a nation-state are expected to do all of the following except __________.
    5·2 answers
  • At its heart, the Scopes Trial was a clash between
    15·2 answers
  • Can amish women go grocery shopping alone?
    11·1 answer
  • What is the answer to thai question?​
    13·1 answer
  • Which region receives rainfall almost daily and has thick,lush vegetation
    12·1 answer
  • Simple security policy awareness requires that _____ report suspicious activity?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!