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
The seven basic parts of a computer are
True [87]
Monitor, keyboard, CPU, mouse, and I believe the USB drive , DVD drive and hardware system
4 0
2 years ago
Read 2 more answers
Why might a peer-to-peer network not be the best choice for a large corporate office setting?
omeli [17]

Answer:

a it is less private

Explanation:

8 0
3 years ago
2.8 Code Practice: Question 1
-BARSIC- [3]

Answer:

The program to this question can be given as:

Program:

#include <stdio.h> //define header file

int main() //define main method.

{

int a1,b1,c1; //define variable

printf("Enter three numbers:\n"); //message

scanf("%d",&a1); //input numbers.

scanf("%d",&b1);//input numbers.

scanf("%d",&c1);//input numbers.

if (a1>b1) //check condition

{

//check condition

if(a1>c1)//inner if block

{

printf("The largest number: %d", a1); //message

}

else  //inner else block

{

printf("The largest number: %d", c1);//message

}

}

else //else block

{

//check condition

if(b1>c1) //inner if block.

{

printf("The largest number: %d", b1);//message

}

else //else block

{

printf("The largest number: %d",c1);//message

}

}

return 0;  //return 0.

}

Output:

Enter three numbers:

22

44

11

The largest number: 44

Explanation:

The description of the above program can be given as:

  • In the C language program firstly we define the header file. Then we define the main function. In the main function, we define three variables that are "a1, b1 and c1". In this variable, we take input from the user.
  • Then we define the conditional statements. In the if block we check if the value of a1 is greater then the value of b1 if this condition is true so we use another condition that if the value of a1 is greater then the value of c1. so, it will print the largest value. If the above condition is not true then it will go to else section.
  • In the else part we check the condition that if the value of b1 is greater then the value of c1. if it is true it will print the largest number value.  
4 0
3 years ago
Read 2 more answers
In Broadbent's filter model of attention, the stages of information processing occur in which order?
victus00 [196]

Answer:SENSORY STORE, FILTER, DETECTOR, STM.

Explanation:Donald Broadbent in 1958 stated one of the earliest theory of attention,he stated that physical features of messages are used to select one message for further processing and that all others are lost.This differs from inattentional blindness, which is when you focus hard on something and fail to notice unexpected things entering your visual area. He believes that

Information from all of the stimuli presented at any given time enters a sensory buffer with unlimited capacity.

3 0
3 years ago
You are building a gaming computer and you want to install a dedicated graphics card that has a fast GPU and 1GB of memory onboa
Vilka [71]

Answer:

a. PCI express

Explanation:

<em>PCI express</em> (Peripheral Component Interconnect Express) is a high speed serial bus and commonly used motherboard interface for  Graphics card, wifi, SSDs and HDs hardware connections. Simple PCI can also be used but PCI express has more error detection accuracy lesser number of I/O pins and better throughput as compared to simple PCI.

6 0
2 years ago
Other questions:
  • What can web designers use to control the individual web page layouts for all of the pages on a website?
    7·1 answer
  • Which method allows a computer to react accordingly when it requests data from a server and the server takes too long to respond
    5·1 answer
  • This is not an appropriate business use for a wiki. editing corporate documents getting customer feedback project management pub
    11·1 answer
  • What is it called when you make a reference in the text of a document alerting the reader that you are using information from an
    10·1 answer
  • Extinction of a species is always a negative impact on the Earth.<br><br> True<br> False
    8·1 answer
  • IN THE MOVIE BACK TO THE FUTURE 1985 IS 1985 THE PUBLICATION DATE?WHERE CAN I FIND THE MOVIE?
    6·1 answer
  • Effective presentations vary the color scheme on each slide.<br><br> True<br> False
    5·2 answers
  • Which of the following technologies is the best choice to convey urgent and highly sensitive information?a. Telephone b. Fax Let
    12·1 answer
  • A collection of realated files is called a
    12·1 answer
  • Brainly not working for me not showing any ads or answers
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!