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
P6. In step 4 of the CSMA/CA protocol, a station that successfully transmits a frame begins the CSMA/CA protocol for a second fr
Karo-lina-s [1.5K]

Answer:

To avoid collision of transmitting frames.

Explanation:

CSMA/CA, carrier sense multiple access is a media access control protocol of wireless networks that allows for exclusive transmission of frames and avoidance of collision in the network. When a frame is not being sent, nodes listening for an idle channel gets their chance. It sends a request to send (RTS) message to the access point. If the request is granted, the access point sends a clear to send (CTS) message to the node, then the node can transmit its frame.

Many nodes on a wireless network are listening to transmit frames, when a frame is transmitting, the node has to wait for the access point to finish transmitting, so it sends a RTS message again to exclusively transmit a second frame.

8 0
4 years ago
Question 4 Multiple Choice Worth 5 points)
Morgarella [4.7K]

The correct answer is Boolean logic.

Booleans are true or false statements.

An example of a while loop is:

while 1 < 5:

   #do something.

The Boolean statement is 1 < 5 which evaluates to true because 1 is less than 5.

I hope this helps!

3 0
3 years ago
Help me. its due tonight
Novosadov [1.4K]
d- enjoy
b- national service !
5 0
3 years ago
Question 9
Irina18 [472]

Answer:

Outsourcing

Explanation:

The boom in collaboration between U.S. companies and workforces in India created a need for Outsourcing.

I believe this is correct, but I'm not 100% certain.

8 0
2 years ago
Multiple Intelligence Theory explains that...
Alex

Answer:

A. We all learn differently (edge 2020)

Explanation:

4 0
3 years ago
Read 2 more answers
Other questions:
  • What is the expected number of jacks-or-better cards in a five-card hand?
    10·1 answer
  • B. Write a function that takes one double parameter, and returns a char. The parameter represents a grade, and the char represen
    7·1 answer
  • 9) If you are working on the part of 5-15 minutes, time-stamping (every 30 seconds) should start at: a) [00:05:00] b) [00:00:00]
    13·1 answer
  • True/False: When a programmer creates an abstract data type, he or she can decide what values are acceptable for the data type,
    8·1 answer
  • If a small monster collector:- Has 16 small monster containment devices and intends to use all of them.
    10·1 answer
  • One interesting application of two-dimensional arrays is magic squares. A magic square is a square matrix in which the sum of ev
    8·1 answer
  • Which vulnerability can occur if a programmer does not properly validate user input and allows an attacker to include unintended
    13·1 answer
  • Write function that ask for input from a user. Use this input as input for the countdown function that we wrote using the while
    6·1 answer
  • Which statement best describes a social impact of computing on the world?
    9·1 answer
  • What feature is required to track customer search terms on a website?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!