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
love history [14]
3 years ago
8

Take two String inputs of the same length and merge these by taking one character from each String (starting with the first ente

red) and alternating. If the Strings are not the same length, the program should print "error".
Sample Run 1:

Enter Strings:
balloon
atrophy
baatlrloopohny
Sample Run 2:

Enter Strings:
terrible
mistake
error
Computers and Technology
2 answers:
ArbitrLikvidat [17]3 years ago
6 0

Answer:

Written in Python

print("Enter strings: ")

str1 = input()

str2 = input()

if len(str1) == len(str2):

     for i in range(0,len(str1)):

           print(str1[i]+str2[i], end='')

else:

     print("Error")

Explanation:

Prompts user for two strings

print("Enter strings: ")

The next two lines get the input strings

str1 = input()

str2 = input()

The following if condition checks if length of both strings are the same

if len(str1) == len(str2):

If yes, this iterates through both strings

     for i in range(0,len(str1)):

This prints the the characters of both strings, one character at a time

           print(str1[i]+str2[i], end='')

If their lengths are not equal, the else condition is executed

else:

     print("Error")

Igoryamba3 years ago
4 0

import java.util.Scanner;

public class JavaApplication89 {

   

   public static void main(String[] args) {

       Scanner scan = new Scanner(System.in);

       System.out.println("Enter Strings:");

       String word1 = scan.nextLine();

       String word2 = scan.nextLine();

       String newWord = "";

       if (word1.length() != word2.length()){

           newWord = "error";

       }

       else{

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

               newWord += word1.charAt(i)+""+word2.charAt(i);

           }

       }

       System.out.println(newWord);

   }

   

}

This is the java solution. I hope this helps!

You might be interested in
True or false? The following deterministic finite-state automaton recognizes the set of all bit strings such that the first bit
aleksklad [387]

Answer:gjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj

Explanation:

7 0
3 years ago
Hilarious error messages
Lilit [14]

Answer:

F

Explanation:

7 0
3 years ago
Read 2 more answers
List three types of Software:
Elodia [21]

Answer:

ummm

Explanation:

Freeware

Open Source

Shareware

5 0
3 years ago
Which one of the following is not possible to view in the debug logs?
Usimov [2.4K]

Answer:

Formula field calculations

Explanation:

We can use debug logs to track events in our company, these events are generated if active users have trace indicators.

A debug log can register information about database operations, system processes and errors, in addition, we can see Resources used by Apex, Workflow Rules, Assignment Rule, HTTP calls, and Apex errors, validation rules. The only one we cannot see is Formula field calculations.

8 0
3 years ago
What are some facts about webmasters?
FromTheMoon [43]
Webmasters monitor  the server to be sure  it is  running,Some webmasters decide what kind of  computer will hold a websites information ,Some webmasters abuse other sites by exploiting their comment fields.
4 0
3 years ago
Other questions:
  • A company decides to reduce its IT labor force by hiring an external company to manage various aspects of IT administration, suc
    6·1 answer
  • What tab must you click on to view any previously read messages from instructors in the message center?
    14·2 answers
  • To copy text in a Word document to an Excel spreadsheet, you should first format the text as a Word table or as text separated b
    11·2 answers
  • For which task is the WordArt gallery most useful?
    15·2 answers
  • Professional photography is a competitive job field. <br> true <br> false
    12·2 answers
  • When an organization uses cloud computing, they do not have to buy and maintain expensive hardware. Group of answer choices True
    6·1 answer
  • PLEASE HELP!!!!!!!!!!! The Excel tool that extends the height of a selected cell so that all the text fits into the cell and is
    10·2 answers
  • Jonathan works with a team of graphic designers. They have a collection of images and have divided the image editing work among
    5·2 answers
  • 50 POINTS!!!!!!!!!!!<br><br> Give at least two examples of how the transport layer is used.
    13·2 answers
  • Classes that depend on field names from parent classes are said to be ____ because they are prone to errors.Group of answer choi
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!