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 freedoms does the First Amendment give US citizen?
REY [17]
<span>RELIGION
</span><span>SPEECH
</span><span>THE PRESS</span>
5 0
3 years ago
Read 2 more answers
Which of the following is an unlearned, complex behavior exhibited by all members of a species?
krek1111 [17]

Answer:

Instinct

Explanation:

Instinct is a phenomenon that describes the unlearned behavior. Instinct is described in relation to motivation. Instinct also occurs in response to the person or animal needs that satisfy some innate internal derives.

Instincts are the term that found out in all the species and is consistent among all the species. Several organisms have faith in instinct behavior. In an organism, one of the organism carry instinct behavior then all species do same.

Instinctual find out in a variety of the species. Instinctual behavior serves in different purposes and found out in the different levels of development of the species.

6 0
3 years ago
Criminologists try to create valid and ___________ measurements of criminal behavior by accessing records, research, and statist
fredd [130]

Answer:

reliable

Explanation:

Criminologists try to create valid and <u>reliable</u> measurements of criminal behavior by accessing records, research, and statistical data to understand patterns and trends.  criminologist do this study in order to prevent further victims of the crime, and to help apprehend perpetrators.

7 0
4 years ago
When did the tectonic history of the Appalachian Mountains begin?
Nezavi [6.7K]

Answer:

480 million years ago

The Appalachians first formed roughly 480 million years ago during the Ordovician Period, and once reached elevations similar to those of the Alps and the Rocky Mountains before they were eroded.

Explanation:

so b is your answer

5 0
3 years ago
What is great change that has occurred to the new south?
STALIN [3.7K]

Answer:

With the industrialization of the South came economic change, migration, immigration and population growth. Light industries would move offshore, but has been replaced to a degree by auto manufacturing, tourism, and energy production, among others.

<h2><u>PLEASE MARK ME BRAINLIEST, PLEASE</u></h2>

4 0
3 years ago
Other questions:
  • A tmporary committee created to resolve differences in versions of a similar bill is called a?
    11·1 answer
  • What is a example of democracy?
    15·1 answer
  • In order to understand the aggressive behavior of an adolescent client, a clinical psychologist has carefully investigated the a
    9·1 answer
  • Media coverage of the Selma March for voting rights, passage of the Voting Rights Act of 1965,
    15·1 answer
  • Southwest Airlines promotes its Rapid Rewards program to reward frequent flyers with benefits like free travel vouchers, priorit
    15·1 answer
  • If a group of citizens believes smoking should be outlawed in all common areas within their state, they have a right to express
    5·2 answers
  • One way humans impact the ecosystem and two ways we can reduce our impact.
    6·1 answer
  • Which of the following do producers pay attention to in order to know what people want to buy and how much they’re willing to pa
    10·1 answer
  • Where is weed recreationally legal in the world 2021
    9·1 answer
  • Question 25/25
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!