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
How do you predict 2 ways the Jamestown colonists died? Explain how you know
lorasvet [3.4K]

Answer:

by diseases of mosquitos and sickness like chicken pocks

Explanation:

bevause of mosquitos a lot of people died of malaria and for chicken pocks they didn't have a medicine for it and many people died for this.

8 0
3 years ago
Need help quick please
frutty [35]
Aye the answer is 2 for sure
4 0
3 years ago
I NEED HELPPP
love history [14]

Answer:

B

Explanation:

7 0
3 years ago
The more we learn about the brain, the more we see it as a blank slate 2. what does religion provide 3. _____ is about the exist
Daniel [21]
<span> 
</span>Religion provides explanations, social order, comfort, <span>and illusion.
</span>Religion is about the existence and causal powers of nonobservable entities and agencies. The religion involves a set of beliefs concerning the cause, nature, and purpose of the universe

According to intellectualism if a phenomena is common in human experience and people do not have the conceptual means to understand it, they will try and find some speculative explanation.
According to Richard Dawkins, culture is a population of memes which are just "copy me" programs.
<span>This British evolutionary biologist, ethologist, and popular-science writer  emphasized the gene as the driving force of evolution.</span>
7 0
3 years ago
Read 2 more answers
Which type of account typically has very high liquidity, low or no interest, and low minimum balance?
andrey2020 [161]

The type of account that has very high liquidity, low interest or no interest at all with a low minimum balance is checking account. The checking account is usually the ones used by a company because of different purposes and it has the following functions which are mentioned above. Making it easier and reliable for them to use.

8 0
3 years ago
Other questions:
  • The burden of health disparities continues to affect disproportionately which population(s)?
    13·1 answer
  • A commonality shared between the Asians who crossed the Bering Strait and the Europeans who crossed the Atlantic Ocean thousands
    7·1 answer
  • Which activity is the best example of cardiovascular and strength-training exercises working together? A football player sprints
    12·2 answers
  • Libya is to Africa as Venezuela is to where?
    15·1 answer
  • What’s the answer??????
    7·1 answer
  • Why are intermediate products excluded from macroeconomic calculations of GDP?
    5·1 answer
  • What do you mean by enjoy diversity?
    7·1 answer
  • How does financial resource influence the development of a nation? write in two sentences.<br>​
    11·2 answers
  • A religion in which followers become involved in practices such as fasting or celibacy to separate themselves from worldly attac
    14·1 answer
  • at 8:30 p.m., the horstman children are expected to brush their teeth and go to bed. this is an example of what type of rule?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!