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 are the common characteristics of nucleated settlements
Anastaziya [24]
A nucleated village<span> or </span>clustered settlement<span> is one of the main types of </span>settlement<span> pattern. It is one of the terms used by geographers and </span>landscape historians<span> to classify settlements.</span>[1]<span> It is most accurate with regard to planned settlements: its concept is one in which the houses, even most farmhouses within the entire associated area of land, such as a </span>parish<span>, cluster around a central church, which is close to the </span>village green<span>. Other focal points can be substituted depending on cultures and location, such as a commercial square, circus, crescent, a railway station, park or a sports stadium.</span>
4 0
3 years ago
What were the three decisions that came from the estates general?
Slav-nsk [51]
I think the three decisions made by the estates-general are the following:
a. Summoning the Estates wherein the nobles and peasants convened after they were summoned by King Louis XVI
b.The Estates-General convened and created the Edict of 24 January 1789 to tackle the current financial difficulties of France
C. After the convention, the Estate had continued to tackle the issues with proceedings and created various solutions to the ongoing debt of the country.

6 0
3 years ago
What work can i apply if i take BSBA on college?
Korvikt [17]

Answer:

If you Graduated that would open alot up for jobs that are looking for help with admin.

Explanation:

6 0
3 years ago
Who usually handles diplomatic work?
Bad White [126]
The diplomats hand the diplomatic work.
7 0
3 years ago
The load is the pivot point of a lever.
madam [21]

Answer:

Pivot – the point around which something turns

Beam – a wooden plank or solid rod that rests on the pivot

Load – the item or object being moved or lifted on the beam

Force – the effort or input needed to move the beam and the load

7 0
3 years ago
Other questions:
  • How does it help the economy that banks offer incentives to get customers to deposit money with them
    8·1 answer
  • Discuss the role of government in each of the different economic models: pure centrally planned, pure market, market economy, an
    15·1 answer
  • ____________ can be viewed as any change in beliefs, attitudes, and behavior resulting from personal experience, mental interpre
    13·1 answer
  • Under the Articles of Confederation, the National Government could NOT:
    13·1 answer
  • In which of the following stages of the buyer decision process does a consumer compare multiple products with similar attributes
    5·1 answer
  • Opportunity cost is the __________.
    6·2 answers
  • Physical activity helps to reduce a person's risk for certain chronic diseases such as high blood pressure, stroke, cardiovascul
    12·1 answer
  • Let's Dish is a meal-preparation service operating in three states. Customers visit a Let's Dish store to select and partially p
    8·1 answer
  • please help ill give brainliest 5 stars thank you and more and the bill is Families First Coronavirus Response Act please help
    15·1 answer
  • ...........................................
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!