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
Of the following traits and abilities, which one would George Herbert Mead consider most essential for an individual to be a ful
alina1380 [7]

Answer:

The correct answer is ''ability to take the role''.

Explanation:

George Herbert Mead was a social psychologist who explained that the human societies in which we are interested are forest societies. The human individual is a self, only insofar as he takes the attitude of the other towards himself. Insofar as that attitude is that of a certain number of others, insofar as he can adopt the organized attitudes of a certain number of others who are cooperating in a common activity, he takes the group's attitudes towards himself, by taking that or those attitudes, is defining the object of the group that which defines and controls response. For Mead this is possible insofar as people are capable of internalizing the behavior of others, we are capable of acting knowing the behavior that others will do. By internalizing the "generalized other", that is, the attitudes of others, the individual behaves in a certain way.

4 0
3 years ago
Where is Alcatraz? My teacher told me it’s in San Antonio
aniked [119]
It's located in San Francisco Bay
5 0
3 years ago
Why would a country impose a quota?
Yakvenalex [24]
Wich gn wound sondbrnwhaidjfgbewowokdfnnf
8 0
3 years ago
When do we usually travel by aeroplanes?​
hichkok12 [17]

Answer:

To get to a far away place fast

5 0
2 years ago
Read 2 more answers
Describe how the people and goods traveled the long roads of the Inca empire
Dafna1 [17]
 some of the Incas used camels/lamas to transport the trade across their dirt road is you look on google maps you can see their roads
3 0
3 years ago
Other questions:
  • How does president Theodore Roosevelt’s comment, “speak softly and carry a big stick” relate to the President’s powers as a dipl
    11·1 answer
  • What do spanish people put on graves to bribe evil spirits away?
    8·1 answer
  • PLZ HELP ASAP
    6·2 answers
  • What similarities do you see between this situation in Haiti with the current coronavirus ​
    6·1 answer
  • You are out camping in a remote area. The next day, you plan to hike the mountain trail and return to camp before dusk. Your fri
    9·1 answer
  • Is this true or false? It's right by the end of World War I.
    14·1 answer
  • What evidence can you find that Rome was growing and becoming more complex?
    15·1 answer
  • Why do cities with large populations vote democrat
    10·1 answer
  • How did the roman republic come to an end bullet points please
    14·1 answer
  • In the u.s. public education system an unexpected outcome is that students often learn to love the u.s. and be patriotic. This l
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!