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
SpyIntel [72]
3 years ago
14

Given a pattern as the first argument and a string of blobs split by | show the number of times the pattern is present in each b

lob and the total number of matches.Input:The input consists of the pattern ("bc" in the example) which is separated by a semicolon followed by a list of blobs ("bcdefbcbebc|abcdebcfgsdf|cbdbesfbcy|1bcdef23423bc32" in the example). Example input: bc;bcdefbcbebc|abcdebcfgsdf|cbdbesfbcy|1bcdef23423bc32Output:The output should consist of the number of occurrences of the pattern per blob (separated by |). Additionally, the final entry should be the summation of all the occurrences (also separated by |). Example output: 3|2|1|2|8 where bc was repeated 3 times, 2 times, 1 time, 2 times in the 4 blobs passed in. And 8 is the summation of all the occurrences. (3+2+1+2 = 8)Test 1:Input: aa;aaaakjlhaa|aaadsaaa|easaaad|saOutput: 4|4|2|0|10Code to be used:import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.nio.charset.StandardCharsets;public class Main {/** * Iterate through each line of input. */public static void main(String[] args) throws IOException {InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);BufferedReader in = new BufferedReader(reader);String line;while ((line = in.readLine()) != null) {String[] splittedInput = line.split(";");String pattern = splittedInput[0];String blobs = splittedInput[1];Main.doSomething(pattern, blobs);}} public static void doSomething(String pattern, String blobs) {// Write your code here. Feel free to create more methods and/or classes}}
Computers and Technology
1 answer:
Ierofanga [76]3 years ago
5 0

Answer:

The code is below

Explanation:

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.nio.charset.StandardCharsets;

public class Main {

  /**

  *

  * Iterate through each line of input.

  *

  */

  public static void main(String[] args) throws IOException {

      InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);

      BufferedReader in = new BufferedReader(reader);

      String line;

      while ((line = in.readLine()) != null) {

          String[] splittedInput = line.split(";");

          String pattern = splittedInput[0];

          String blobs = splittedInput[1];

          Main.doSomething(pattern, blobs);

      }

  }

  public static void doSomething(String pattern, String blobs) {

      // Write your code here. Feel free to create more methods and/or classes

      int sum = 0;

      String arrblobs[] = blobs.split("\\|");

      for (int i = 0; i < arrblobs.length; ++i) {

          int answer = 0, index = 0;

          for (;;) {

              int position = arrblobs[i].indexOf(pattern, index);

              if (position < 0)

                  break;

              answer++;

              index = position + 1;

          }

          System.out.print(answer + "|");

         

          sum = sum + answer;

      }

      System.out.println(sum);

  }

}

You might be interested in
How many times would the code in this loop repeat? ____________ for ( j = 0; j &lt; 10; j++ ) { appendItem (myList, aNumber); }
Musya8 [376]

Answer:

The answer to this question is given below in the explanation section.

Explanation:

The for-loop given in the question is:

for ( j = 0; j < 10; j++ )

{

      appendItem (myList, aNumber); //this loop append a number to a list myList

}

This loop starts from J variable's value zero and when J's value is less than 10, the loop iterate through its body until J's value becomes greater or equal to 10. As J's value exceed nine, the loop will get terminated.

So this loop repeats 10 times its loop body, at the 11th time, the condition becomes false and the loop will get terminated.

4 0
3 years ago
Jement Tools
Yuki888 [10]

Explanation:

I think it's either c or d but I don't remember

7 0
2 years ago
I NEED HELP ASAP IM BAD AT THIS
ra1l [238]

A float is a floating point number. This means that's the number has a decimal place. Numbers with or without decimal places can be stored in a float variable but more commonly numbers with decimal points.

The correct choices are 1 and 3.4

4 0
3 years ago
Lists and Procedures Pseudocode Practice For each situation, provide a pseudocoded algorithm that would accomplish the task. Mak
Andrei [34K]

Answer:

The pseudocoded algorithm is as follows:

Procedure sumOdd(lotsOfNumbers):

    oddSum = 0

    len = length(lotsOfNumbers)

    for i = 0 to len - 1

         if lotsOfNumbers[i] Mod 2 != 0:

              OddSum = OddSum + lotsOfNumbers[i]

Print(OddSum)

Explanation:

This defines the procedure

Procedure sumOdd(lotsOfNumbers):

This initializes the oddSum to 0

    oddSum = 0

This calculates the length of the list

    len = length(lotsOfNumbers)

This iterates through the list

    for i = 0 to len-1

This checks if current list item is odd

         if lotsOfNumbers[i] Mod 2 != 0:

If yes, the number is added to OddSum

              OddSum = OddSum + lotsOfNumbers[i]

This prints the calculated sum

Print(OddSum)

6 0
3 years ago
provide(s) many scalability benefits by offering additional network and storage resources on demand and services like autoscalin
Salsk061 [2.6K]

Answer:

The answer is cloud services.

Explanation:

The other answer choices just don't make sense. Python is a coding language and has nothing to do with scalability. Benchmarking has to do with finding out how powerful your system is. Denial of Service is when a website doesn't allow you to access it due to their servers being down.

6 0
3 years ago
Other questions:
  • Which one of the following downloads and uploads files to and from a server? A. Client B. Internet protocol C. Server D. Worksta
    9·1 answer
  • You are an interior decorator, confronted with a dark living room. To lighten the room up, you have n candles and want to build
    12·1 answer
  • If involved in a boating accident causing serious bodily injury or death while boating under the influence, the operator has com
    15·1 answer
  • The correct order of operations is _____. brackets, exponents, division, multiplication, addition, and subtraction subtraction,
    5·2 answers
  • What do people in japan use to make anime
    5·1 answer
  • Which of the following best describes professional behavior in the IT field?
    6·1 answer
  • 50 POINTS!!!!!!!!!!!<br><br> Give at least two examples of how the transport layer is used.
    13·2 answers
  • Which interpersonal skill is the most important for a telecom technician to develop?
    7·1 answer
  • Arrange the code so that the numbers are swapped.
    11·1 answer
  • Byte pair encoding is a data encoding technique. The encoding algorithm looks for pairs of characters that appear in the string
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!