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]
2 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]2 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")

Igoryamba2 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
Yo, my Lenovo laptop keeps showing this screen but I can't sign in, can someone help me?
rusak2 [61]
Break your laptop and get a new one
8 0
2 years ago
Read 2 more answers
I'm trying to network two laptops together using ethernet cable but it isn't working. Why isn't it working
Nonamiya [84]

On modern network cards, this should just work.

It is advisable to give each laptop its own fixed IP address, such as 192.168.1.1 and 192.168.1.2 (with a netmask of 255.255.255.0)

However, you need to define what you expect to work. The first thing to try is ping <em>the other</em> machine from the command prompt, e.g.:

C:\> ping 192.168.1.2

Then, you can try to access shared network drives if you have enabled that. In the file explorer, try typing: \\192.168.1.2

5 0
3 years ago
How many megapixels is in a macbook air 2017 camera
Anastasy [175]

Answer:

.7

Explanation:

3 0
3 years ago
What can be designed to create annoying glitches or destroy data
Yanka [14]
Viruses can cause this.
3 0
3 years ago
Something the user knows (ID and password); something the user has (such as a smart card, which is a credit card device storing
Vlad1618 [11]

Answer:

Secure Authentication involves a combination of the following three information

Explanation:

Generally, it is important that users have access to secure sources of information or data. These data will be used by the users to get access to their platform such as account details. The user should also be the only person that has access to his or her vital information. This should not be disclosed to any other person.

8 0
3 years ago
Other questions:
  • Enhancing and optimizing customer retention and loyalty is a major business strategy.
    15·1 answer
  • The calls radioed to patrol officers, or assignments given to police patrol units by 911 dispatchers, reveal the types of proble
    9·1 answer
  • What does the rule of five say?
    12·2 answers
  • Working for the Internal Revenue Service is a career in public safety. A. True B. False
    14·1 answer
  • Write a program which increments from 0 to 20 and display results in Decimal on the console 2-b) Modify above program to increme
    6·1 answer
  • Any material that comes into contact with the body must be __________.
    6·1 answer
  • Choose all stages of the information processing cycle.
    12·2 answers
  • Question #5
    15·2 answers
  • Copying materials from a source text without using is<br> considered plagiarism<br> ?
    5·1 answer
  • Question 1 Which portion of the PuTTY package allows you to perform file transfers using the SCP (Secure Copy) protocol?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!