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
Who is katie and why is she deleting my answers
defon

Answer:

fr its so annoying when they delete your stuff when there is legit nothing wrong with the question

Explanation:

8 0
2 years ago
Read 2 more answers
True or false? The History list shows only Web pages you visited during the current computing session. -computer essentials
Deffense [45]

Answer:

Yes, but if you click on your history you can see all of what you went on for a few days back

Explanation:

4 0
3 years ago
How exactly do you find the circumference by using C++ Programming? I really need a specific answer.
adelina 88 [10]

Answer:

C++ Program to Find Area and Circumference of a Circle

Area of Circle = PI X Radius X Radius. Where, Where PI is a constant which is equal to 22/7 or 3.141(approx)

Circumference or Circle = 2 X PI X Radius.

Circumference or Circle = PI X Diameter.

Explanation:

3 0
3 years ago
An email message containing a warning related to a non-existent computer security threat, asking a user to delete system files f
LenKa [72]

Answer: Virus Hoax

Explanation:

A computer virus hoax is a message that warns someone of a false virus threat. It is a a chain email that encourages who ever has received the message to pass it to other people as a form of warning.

5 0
3 years ago
What are the three fundamental principals of mnemonics??
olasank [31]
The three fundamental principles underlying the use of mnemonics are imagination, association and location
4 0
3 years ago
Read 2 more answers
Other questions:
  • What is one important feature of an aup? 1. a list of all available courses. 2. a clear out line of the consequences of violatin
    12·2 answers
  • Please help! (I cant figure out)
    13·1 answer
  • Liz's meeting is scheduled to end at 9:30. It is 9:20 and team
    9·1 answer
  • Mercury Technical Solutions has been using SSL in a business-to-business environment for a number of years. Despite the fact tha
    5·1 answer
  • Spoken word and written word are different because what
    9·1 answer
  • The___provides access to the internet; may also be internal
    11·1 answer
  • Data types influence the following in the workflow: (Select all that apply)a. the color choices and layout decisions around comp
    15·2 answers
  • Jim wants to buy a car, but he’ll probably only need it for a couple of years. He has a short commute to work, so he won’t be pu
    10·1 answer
  • Define stubs for the functions called by the below main(). Each stub should print "FIXME: Finish FunctionName()" followed by a n
    7·1 answer
  • Name three types of hard drives, along with its speed and size.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!