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
Accenture has partnered with a global construction company that specializes in building skyscrapers. The company wants better ma
aleksandrvk [35]

Answer: d. past maintenance and performance records and worksite conditions.

Explanation:

When improvements need to be made on anything, it is important to know what is to be improved upon as the very first step.

The data required here therefore, is the past performance and maintenance records as well as worksite conditions. This will enable Accenture know what it is they need to improve upon and how much improvement is needed.

8 0
1 year ago
A credit card company receives numerous phone calls throughout the day from customers reporting fraud and billing disputes. Most
Veronika [31]

Answer:

3.59 minutes

Explanation:

We solve this question using z score formula

Using Excel

Z-SCORE= (DataPoint-AVERAGE(DataSet))/STDEV(DataSet)

IN EXCEL,

AVERAGE, an excel function that calculates the Average of data set

STDEV.S: calculates the standard deviation while treating the data as a ‘sample’ of a population.

STDEV.P: This function calculates the standard deviation while treating the data as the entire population.

Z score formula = x - μ/σ

x = ?? μ = 2.5 minutes σ = 0.5 minutes

We are asked : If 1.5% of the callers are put on hold for longer than x minutes, what is the value of x?

Hence, Longer than = Greater than =

100 - 1.5%

= 100 - 0.015

= 0.985 ( 98.5%)

Using Excel we calculate = z score for 98.5 percentile

= 2.1701

Z score = x - μ/σ

2.1701 = x - 2.5/0.5

2.1701 × 0.5 = x - 2.5

1.08505 = x - 2.5

x = 1.08505 + 2.5

x = 3.58505

Approximately to 2 decimal places = 3.59 minutes

Therefore, 1.5% of the callers are put on hold for longer than 3.59 minutes.

8 0
2 years ago
Consider the following two code segments, which are both intended to determine the longest of the three strings "pea", "pear", a
Nikolay [14]

Answer:

e) Code segment II produces correct output for all values of str, but code segment I produces correct output only for values of str that contain "pea" but not "pear".

Explanation:

<em>if - elseif - else statements work in sequence in which they are written. </em>

  • <em> </em>In case <em>if() statement is true, </em>else if() and else statements will not get executed.
  • In case <em>else if() statement is true</em>, conditions in if() and else if() will be checked and else statement will not be executed.
  • In case <em>if() and else if() both are false</em>, else statement will be executed<em>.</em>

First, let us consider code segment I.

In this, first of all "pea" is checked in if() statement which will look for "pea" only in the String str. So, even if "pearl" or "pear" or "pea" is present in 'str' the result will be true and "pea" will get printed always.

After that there are else if() and else statements which will not get executed because if() statement was already true. As a result else if() and else statements will be skipped.

Now, let us consider code segment II.

In this, "pearl" is checked in if() condition, so it will result in desired output.

Executable code is attached hereby.

Correct option is (e).

Download java
<span class="sg-text sg-text--link sg-text--bold sg-text--link-disabled sg-text--blue-dark"> java </span>
<span class="sg-text sg-text--link sg-text--bold sg-text--link-disabled sg-text--blue-dark"> java </span>
3 0
2 years ago
1. PLCs were originally designed as replacements for: a) microcomputers. c) analog controllers. b) relay control panels. d) digi
timama [110]

Answer:

PLCs (Programmable logic controller) were original designed as replacement for relay control panels.  Relay is another word for a switch. Relay control panels were made for the control of electronic instrumentents or devices. Later on PLCs were made to replace these timers and relay control panels. PLCs are more reliable, flexible and can work better in the harsh environmental situations then the relay control panels.

3 0
2 years ago
Consider the following class definitions.
Serggg [28]

Answer:

The correct answer is option A

Explanation:

Solution

Recall that:

From the question stated,the following segments of code that should be used in replacing the /* missing code */ so that the value 20 will be printed is given below:

Android a = new Android(x);

a.setServoCount(y);

System.out.println(a.getServoCount());

The right option to be used here is A.

4 0
2 years ago
Other questions:
  • Explain the following instructions: ADD 3000, 1050, 1900.
    12·1 answer
  • Which word in brackets is most opposite to the word in capitals? PROSCRIBE (allow, stifle, promote, verify)​
    14·2 answers
  • A website updated daily could be considered _____. a. authoritative b. objective c. accurate d. timely
    8·1 answer
  • Suppose that, even unrealistically, we are to search a list of 700 million items using Binary Search, Recursive (Algorithm 2.1).
    11·1 answer
  • The ______ network became functional in 1969, linking scientific and academic researchers across the United States. Group of ans
    7·2 answers
  • Write a function called st_dev. St_dev should have one #parameter, a filename. The file will contain one integer on #each line.
    7·1 answer
  • Create an abstract Division class with fields for a company's division name and account number, and an abstract display() method
    14·1 answer
  • Define the instance method inc_num_kids() for PersonInfo. inc_num_kids increments the member data num_kids. Sample output for th
    10·1 answer
  • You should see an error. Let's examine why this error occured by looking at the values in the "Total Pay" column. Use the type f
    14·1 answer
  • _____________ data is what is translated to digital format so it can be stored in a computer.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!