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
When someone is excommunicated from the church, they are _____. taken away to jail banned from attending the church or communica
algol13
Banned from attending the church.....
4 0
3 years ago
Read 2 more answers
PLEASE HELP!!! I will love you forever if you help me✅❤️ Social studies/history
Ivan

Answer:

Slaves had few legal rights: in court their testimony was inadmissible in any litigation involving whites; they could make no contract, nor could they own property; even if attacked, they could not strike a white person. There were numerous restrictions to enforce social control: slaves could not be away from their owner’s premises without permission; they could not assemble unless a white person was present; they could not own firearms; they could not be taught to read or write, nor could they transmit or possess “inflammatory” literature; they were not permitted to marry.

This is for question 11

Explanation:

4 0
2 years ago
Which of the following is not a part of the expense in a public school system
ohaa [14]
Answer is capital outlay <span />
3 0
3 years ago
Grace developed schizophrenia quite suddenly after being sexually assaulted in a parking lot. grace is responding to medication
Stella [2.4K]
<span>Acute. Acute onset means a sudden onset. It says that she quickly and suddenly developed symptoms of schizophrenia.</span>
8 0
3 years ago
How did Mansa Musa contribute to the economic success of Mali?
Lyrx [107]

Because of Mansa Musa's pilgrimage across the world (where he showcased his wealth) the kingdom of Mali gained enormous economic success and recognition. When he went on tour showcasing his wealth to everyone he saw, he arguably became the worlds first 'celerity'. Because of his immense wealth and popularity, word got around quickly on how powerful and wealthy the kingdom of Mali is, and many scholars and all sorts of people flocked to Mali. Mansa Musa built mosques and learning centers, and Mali became a hub of learning and a bustling city. Because Mansa Musa gained celerity like status, others recognized Mali as a good place to make money, learn, worship, and live. Because of this boost of population, Mali's economy grew immensely.

Hope this helps! (you might want to look up certain dates and specifics of his pilgrimage, I hope this is a good outline though!)

3 0
3 years ago
Other questions:
  • Socio economic events after 2063 bs
    10·1 answer
  • According to denise park, much of the blame for declining memory in late middle age is a result of:
    10·1 answer
  • Psychologists with a__________perspective are most likely to investigate the ways we perceive and mentally represent the world,
    6·1 answer
  • Who was president Obama
    7·2 answers
  • Identify the capital and state labeled #8 on the map above.
    11·2 answers
  • What might explain the contradiction that the Northeast has plenty of mining but is still the poorest region of Brazil in terms
    6·1 answer
  • Why did the United States establish an armistice with the North Koreans during the Korean War?
    12·1 answer
  • How do we know that the framework for the Executive Branch is designed to last “forever”?
    9·1 answer
  • The decisions people think about and make every day based on past experiences are called __________.
    10·1 answer
  • Wilberforce, a local cat, is losing his fur. Your neighbor, Mrs. Folmar, remarks
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!