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
iogann1982 [59]
3 years ago
10

Write a static method called bothStart that allows the user to input two Strings and returns the String that is the longest subs

tring s such that both inputs start with s.
For example,


bothStart( "radar dish", "radical food" ) returns "rad"


bothStart( "radar disk", "disk radar" ) returns ""


bothStart( "radar installation", "" ) returns ""


bothStart( "Mendacious", "Mendicant" ) returns "Mend"


bothStart( "FRANKLY", "frank" ) returns ""
Computers and Technology
1 answer:
marishachu [46]3 years ago
5 0

Answer:

  1.    public static String bothStart(String text1, String text2){
  2.        String s = "";
  3.        if(text1.length() > text2.length()) {
  4.            for (int i = 0; i < text2.length(); i++) {
  5.                if (text1.charAt(i) == text2.charAt(i)) {
  6.                    s += text1.charAt(i);
  7.                }else{
  8.                    break;
  9.                }
  10.            }
  11.            return s;
  12.        }else{
  13.            for (int i = 0; i < text1.length(); i++) {
  14.                if (text1.charAt(i) == text2.charAt(i)) {
  15.                    s += text1.charAt(i);
  16.                }else{
  17.                    break;
  18.                }
  19.            }
  20.            return s;
  21.        }
  22.    }

Explanation:

Let's start with creating a static method <em>bothStart()</em> with two String type parameters, <em>text1 </em>&<em> text2</em> (Line 1).  

<em />

Create a String type variable, <em>s,</em> which will hold the value of the longest substring that both inputs start with the same character (Line 2).

There are two possible situation here: either <em>text1 </em>longer than<em> text2 </em>or vice versa. Hence, we need to create if-else statements to handle these two position conditions (Line 4 & Line 13).

If the length of<em> text1</em> is longer than <em>text2</em>, the for-loop should only traverse both of strings up to the length of the <em>text2 </em>(Line 5). Within the for-loop, we can use<em> charAt()</em> method to extract individual character from the<em> text1</em> & <em>text2 </em>and compare with each other (Line 15). If they are matched, the character should be joined with the string s (Line 16). If not, break the loop.

The program logic from (Line 14 - 20) is similar to the code segment above (Line 4 -12) except for-loop traverse up to the length of <em>text1 .</em>

<em />

At the end, return the s as output (Line 21).

You might be interested in
A type of printer is used to price model and shape is called
balandron [24]

Either a 3d,2d printer, or a price label gun

7 0
4 years ago
Write an algorithm to sum to values
Elis [28]

Answer:

There is no need to make an algorithm for this simple problem. Just add the two numbers by storing in two different variables as follows:

Let a,b be two numbers.

c=a+b;

print(c);

But, if you want to find the sum of more numbers, you can use any loop like for, while or do-while as follows:

Let a be the variable where the input numbers are stored.

while(f==1)

{

printf(“Enter number”);

scanf(“Take number into the variable a”);

sum=sum+a;

printf(“Do you want to enter more numbers? 1 for yes, 0 for no”);

scanf(“Take the input into the variable f”);

}

print(Sum)

Explanation:

hi there answer is given mar me as brainliest

5 0
3 years ago
Make the correct match.
faltersainse [42]
<span>1. E 2. B 3. D 4. F 5. C 6. A Let's go about solving this problem in a process of elimination. So I'll be making each match in the easiest (for me) order. Initially I'm not sure about 1 & 2. But the match for #3 is rather obvious. So 3. Blending non-related clips and images to make a new video. This is a "D. Mashup" The next obvious answer is for #6. That is 6. Everything that happens to the video and audio after the footage has been shot. This is "A. Post production" Now of the remaining 4 choices, "Final Cut Pro" sounds like an actual program. And there's only 1 option that's asking for a specific program. So we have 2. Most popular post-production editing package by Apple Answer "B. Final Cut Pro" This leaves us with 3 options "C. Non-linear editing", "E. AVID", and "F. Timeline" Of these 3, only "F. Timeline" sounds list an element in the interface of a video editing package. So we have 4. An element in the interface of editing software Answer "F. Timeline" Now a quick google search reveals that "AVID" is a software company that makes video editing software. So 1. Company that makes high-end post-production software. Answer "E. AVID" And we're left with 5. Transferring film onto Beta, digitizing it to the computer, and editing it Answer "C. Non-linear editing" Now the only questionable choice is Non-linear editing (NLE) for #5. So doing a quick google search and I see that #5 over specified the task. The key characteristic of NLE is having the video and audio in digital form that can be readily accessed via a computer. And #5 does qualify for that task. So here's the final answers 1. E 2. B 3. D 4. F 5. C 6. A</span>
6 0
3 years ago
Use the Manufacturing database from "Excel Databases.xls" on Blackboard. Use Excel to develop a multiple regression model to pre
Dennis_Churaev [7]

Answer:

52.64

Explanation:

Multiple Regression:

Multiple regression generally explains the relationship between multiple independent or predictor variables and one dependent or criterion variable.

Please kindly check attachment for the step by step solution of the given problem.

6 0
3 years ago
Best location to install a patch panel?
sergejj [24]

Answer:

Explanation: In general, there are three positions for the patch panel to install in the stand column of rack, which depends on your cabling. When adopting ground outlet, the cables usually enter inside the rack from its bottom. So the patch panel should be mounted in the lower part inside the rack.

8 0
3 years ago
Other questions:
  • Which Boolean operator enables you to exclude a search term?
    9·2 answers
  • Flashlights are known as which of the following
    7·2 answers
  • What command do you type in the search box to access the command line intrface in windows?
    8·1 answer
  • The shortcut key combination to cut text is. Ctrl+C Ctrl+X Shift+V Shift+Y​
    10·2 answers
  • PLS HELP For this activity, you can use the audio recorder on your cell phone or a digital camera to record the following sounds
    14·1 answer
  • Consider an array of integers consisting of the numbers: 8 12 19 32 45 55 67 72 89 90 92. Suppose the binary search algorithm is
    11·1 answer
  • Unlike when writing in a programming language, there are no set rules that must be followed when writing pseudocode. What do you
    13·1 answer
  • What is Data rate?<br> What is BAUD RATE?<br> What is bandwidth?
    8·1 answer
  • Why do we need to connect computers"​
    11·1 answer
  • Explain employment opportunities in the networking field 
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!