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
Having reviewed dod wireless stig (ver6, release 1), sarah learns she may only utilize secnet 54 and ______________ for transmit
xeze [42]
<span>Sarah learns she may only utilize SecNet 54 and SecNet 11 for transmitting classified information up to top secret.
</span>

SecNet 11 Plus is a family of encrypted <span>802.11b wi-fi <span>networking products. The Army has also approved</span></span> SecNet 11<span> as part of the classified Navy Marine Corps Intranet (NMCI) wireless solution. There are many products in SecNet 11 family, such as SecNet 11 Plus PC card, the SecNet 11 Wireless ridge, and the SecNet 11 Key Fill Cable etc.</span>

7 0
3 years ago
In a five-choice multiple-choice test, which letter is most often the correct
tatiyna

I believe the answer is C.

5 0
3 years ago
Read 2 more answers
Write a program that takes user input describing a playing card in the following short-hand notation:
siniylev [52]

Answer:

In python Language:

cardNotation = raw_input("Enter card notation: ")

 

# Create a dict for values

 

cardColors = {"D": "Diamonds",

             "H": "Hearts",

             "S": "Spades",

             "C": "Clubs"}

 

cardNumberValues = {"A": "Ace",

                   "J": "Jack",

                   "Q": "Queen",

                   "K": "King",

                   "2": "Two",

                   "3": "Three",

                   "4": "Four",

                   "5": "Five",

                   "6": "Six",

                   "7": "Seven",

                   "8": "Eight",

                   "9": "Nine",

                   "10": "Ten"}

 

# Handle cases when 10 comes in input

if len(cardNotation) == 3:

 

   number = cardNotation[:2]

   color = cardNotation[2:]

   print cardNumberValues.get(number) + " of " + cardColors.get(color)

 

elif len(cardNotation) == 2:

 

   number = cardNotation[:1]

   color = cardNotation[1:]

   print cardNumberValues.get(number) + " of " + cardColors.get(color)

 

else:

   print "INVALID VALUE"

6 0
2 years ago
I know this isn't a school question but it is important! how do I get out of hp hardware diagnostics UEFI on hp pc? (step by ste
Debora [2.8K]

Answer:

1. Turn off the computer and wait five seconds.

2. Press the Power button to start the computer and repeatedly press the F10 key to enter the BIOS setup menu.

3. On the BIOS Setup screen, press F9 to select and load the BIOS Setup Default settings.

4. Press F10 to Save and Exit.

5. Use the arrow keys to select Yes, then press Enter when asked Exit Saving Changes?

6. Follow the prompts to restart your computer.

After you have get to the operating system,

1. Press CTRL + Alt + Del on the blank screen.

2. Click on Task Manager

3. Click "File" - "Run a new task" If there is no "file" option, please click on the task manager under the "details"

4. In the pop-up window, enter "msconfig" click "OK"

5. In the system configuration window that appears, click "Service" and uncheck "App Readiness".

6. Click "Apply" --- "OK"

7. In the following window appears to click on the "restart"

6 0
3 years ago
This is Microsoft Word. ONLY RIGHT ANSWERS. 50 points
pishuonlain [190]
She should select the first sentence then press and hold ALT while selecting the second sentence
5 0
2 years ago
Other questions:
  • Explain the difference between general-purpose and specialized applications. Also discuss the common features of application pro
    11·1 answer
  • The BasicSet 2 class implements the Set ADT by wrapping an object of the Linked Collection class and:______.
    15·1 answer
  • Before sharing a document, you must first save the document to
    12·1 answer
  • Today encoding scheme has taken over ascII by what
    5·1 answer
  • What tool can help discover and report computer errors and conflicts that occur when you first turn on a computer and before the
    15·1 answer
  • A message M is encapsulated by the TCP, IP and Ethernet protocols in that order as it travels down a protocol stack. What does t
    5·1 answer
  • If I wanted to include a picture of a dog in my document, I could use _____. SmartArt WordArt clip art AutoCorrect
    13·1 answer
  • Is a pocket watch consider a computer
    15·1 answer
  • REPORT THIS USER. HE'S SHOWING HIS YK WHAT TO EVERYONE INCLUDING ME. HIS ACCOUNT PROFILE IS IN THE PICTURE BELOW
    14·1 answer
  • When creating a shape in Word, what are some available options? Check all that apply. adding text to the shape changing the size
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!