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
IgorC [24]
3 years ago
10

Given the strings s1 and s2 that are of the same length, create a new string consisting of the last character of s1 followed by

the last character of s2, followed by the second to last character of s1, followed by the second to last character of s2, and so on (in other words the new string should consist of alternating characters of the reverse of s1 and s2). For example, if s1 contained hello" and s2 contained "world", then the new string should contain "odlllreohw". Assign the new string to the variable s3.
Computers and Technology
1 answer:
Free_Kalibri [48]3 years ago
7 0

Answer:

See the code snippet in the explanation section

Explanation:

import java.util.Scanner;

public class Question {

   public static void main(String args[]) {

              Scanner scan = new Scanner(System.in);

 System.out.println("Enter first string: ");

 String s1 = scan.nextLine();

 System.out.println("Enter second string: ");

 String s2 = scan.nextLine();

 concatenateString(s1, s2);

 }

 

 public static void concatenateString(String firstString, String secondString){

 int stringLength = firstString.length() - 1;

 String s3 = "";

  if (firstString.length() != secondString.length()){

  System.out.println("String do not have equal length");

 } else {

  for(int i = stringLength; i >= 0; i--){

   s3 += String.valueOf(firstString.charAt(i)).concat(String.valueOf(secondString.charAt(i)));

  }  

  System.out.println(s3);

 }

   }

}

You might be interested in
What list did poe appear on for the search engine lycos?
HACTEHA [7]
What list did Poe appear on for the search engine Lycos"
Millines most wanted number four. Edgar Allan Poe was born on January 19, 1809, in Boston, Massachusetts. His father, named David Poe Jr and his mother, named Elizabeth Arnold Hopkins Poe, were touring actors. 
4 0
3 years ago
The most popular input device of a computer is a(n) ____.
zaharov [31]
A keyboard and a mouse

7 0
3 years ago
A network is a group of two or more computers or devices connected together. To be able to connect, they each need a
Kay [80]
D. Internet service protocol (isp)
6 0
3 years ago
Read 2 more answers
In windows, a hamburger is an icon that, when clicked, displays a(n) _____________.
OleMash [197]
In windows, a hamburger is an icon that, when clicked, displays  three parallel horizontal lines. The hamburger button is a graphical shortcut placed typically in a top corner of the graphical user interface. It is used in small devices (smartphones for example) and the idea is to take less space. <span>The hamburger icon was originally designed by </span>Norm Cox<span> </span>
4 0
2 years ago
Which one bc im struggling
Setler79 [48]

Answer:

cant really see it

Explanation:

3 0
2 years ago
Other questions:
  • Walking paths across the part is represented by the equation why equals -4x - 6​
    9·1 answer
  • Write a function called lucky_sevens that takes in one #parameter, a string variable named a_string. Your function #should retur
    15·1 answer
  • Write a program segment with a do-while loop that displays whether a user-entered integer is even or odd. The code should then a
    5·1 answer
  • Describe the advantages of this trend from the point of view of the patient or the healthcare provider.
    5·1 answer
  • To print a budget:________.
    9·1 answer
  • Write code using the range function to add up the series 99, 98, 97,...
    11·1 answer
  • Exercise#3: Write a program that performs the following: Declare a two arrays called arrayA and arrayB that holds integer and th
    14·2 answers
  • Check My Work Sherri is considering replacing a processor on her laptop. The laptop is running slower than she would like. What
    9·1 answer
  • What do u think a creative app must have? <br><br> Please answer the question ASAP!!
    5·1 answer
  • How can you distinguish between a manually added page break and an automatic page break in a worksheet?.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!