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
How can you create an illusion of spatial depth in a two-dimensional design?
astraxan [27]

Answer:

Using three or more vanishing points within a work to create the illusion of space on a two-dimensional surface.

Explanation:

6 0
2 years ago
Write a program that prompts the user to enter a string (may contain spaces) and displays its last character. Enter s string: Pr
STALIN [3.7K]

Answer:

<em>The programming language in Python is as follows:-</em>

#Prompt user for input string

userinput = input("Enter a string: ")

#Print the last character of the input

print("The last character is "+userinput[-1])

#End of Program

Explanation:

This line is a comment

#Prompt user for input string

This line prompts user for input

userinput = input("Enter a string: ")

This line is also a comment

#Print the last character of the input

This next line prints the last character of the input string; the last character is defined by the index -1

print("The last character is "+userinput[-1])

3 0
3 years ago
Casual or informal group meetings are common. Here youcasually chat over tea, meet after work, or get together for purelysocial
SCORPION-xisa [38]

Answer: True

Explanation:

Yes, it is true that the informal or the casual meetings are very common and you can chat over tea with your friends and colleagues and meet with your childhood friends in purely social meeting. Informal meetings are basically planned for relaxation your mind and mood other than formal business meetings. It does not have any agenda like the formal business meetings.

3 0
3 years ago
In the ____ letter style, all components of the letter begin flush with the left margin.
Sedaia [141]
In the block <span>letter style, all components of the letter begin flush with the left margin.</span>
4 0
3 years ago
Will the fcc ruin the internet affect uk
n200080 [17]
No it will not the FCC is a federal owned company by the United States and has no control over any other servers outside of the US
3 0
3 years ago
Other questions:
  • Why are resources limited? Why can't we get everything all the time?
    12·1 answer
  • _____ provide the standards, syntax, statements, and instructions for writing computer software
    14·1 answer
  • If your BAL is .10 you can expect a _______ drop in complex performance compared to the sober level
    6·1 answer
  • A technician is assigned a task to configure a new server with six hard drives. The senior administrator requested the technicia
    13·1 answer
  • I need a explanation for this 02 question for a test I will have .
    11·1 answer
  • How much is this worth in dollars​
    9·1 answer
  • Question 1 of 20 Gus has decided to organize his inbox on June 26 by using folders and deleting irrelevant messages. He creates
    14·2 answers
  • Write a method, findMax(), that takes in two integers and returns the largest value. Ex: If the program input is: 4 2 the method
    8·1 answer
  • Most effective way of closing email is<br>​
    7·2 answers
  • when inputting a formula into excel or other spreadsheet software, what components are required for the formula to function prop
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!