answer.
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]
2 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]2 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
Dante wants to calculate the currently monthly subtotals for the sales of golf balls in his store. Which of the following will h
cupoosta [38]
I believe the answer is B
3 0
2 years ago
E-mail is an efficient means of disseminating information quickly and inexpensively. However, HIPAA regulations affect e-mail us
oksano4ka [1.4K]

Sending potentially sensitive information by email

Potentially sensitive information can be sent via Email only if the Email is encrypted

Explanation:

No doubt Email is an inexpensive efficient means of communicating quickly. But it is prone to hacking and it is not a secure mechanism. In order to add security ,the Email needs to be sent in an encrypted form. Banking and HIPAA regulations require the emails to be sent in encrypted form as it is a secure mechanism. Even if one has the consent from the client , the Email has to be in encrypted. Even if the Organization's e-mail system has appropriate firewalls and related infrastructure , the golden rule is to send encrypted format Emails.

7 0
2 years ago
A student made a model of isostasy by placing a block of wood in a beaker of water. What does the wooden block represent in the
Komok [63]
I am almost positive the answer is B, Earth's crust. I know it cannot be A or C because isostasy has nothing to do with sea level or glaciers, and Earth's mantle is inside.
7 0
2 years ago
Read 2 more answers
To explain acceptable computer use to their employees, students, or other users, many organizations and educational institutions
docker41 [41]

Answer:

Codes of conduct

Explanation:

Codes of conduct are a set of rules or norms established by an organization for all employees, students or users, to ensure individual responsibilities and proper practices. The code of conduct can cover overall behaviour of individuals in an organization, but a specific code of conduct can be developed for proper computer use in order to establish what is appropriate and available to use in the organization´s computers, and also to restrict or avoid non related content.

7 0
2 years ago
Read 2 more answers
John downloaded the manual for his TV, called manual-of-tv.pdf, from the manufacturer's website. After he clicked twice on the d
wariber [46]

Jhon must download third party pdf viewer softwares to open the .pdf file.

For example

Adobe Acrobat Reader

Must click thanks and mark brainliest

4 0
2 years ago
Other questions:
  • Which of the following blocks is least similar to the others?
    8·2 answers
  • __________ access control is a form of __________ access control in which users are assigned a matrix of authorizations for part
    8·1 answer
  • Which of the following can you NOT apply for at any FLHSMV office? A. Certificate of title B. License plates C. Vehicle registra
    15·2 answers
  • Write a program that calculates an adult's fat-burning heart rate, which is 70% of 220 minus the person's age. Complete fat_burn
    13·1 answer
  • A 1.17 g sample of an alkane hydrocarbon gas occupies a volume of 674 mL at 28°C and 741 mmHg. Alkanes are known to have the gen
    14·1 answer
  • Sites like Zillow get input about house prices from a database and provide nice summaries for readers. Write a program with two
    12·1 answer
  • CodeLab Question
    12·1 answer
  • Your company has decided to replace several hundred hard drives. It would like to donate the old hard drives to a local school s
    11·1 answer
  • Which of the following statements is true regarding input and output?
    12·2 answers
  • Create a different version of the program that: Takes a 3-digit number and generates a 6-digit number with the 3-digit number re
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!