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
Your auto insurance policy has a $200 monthly premium and $700 deductible. what is the maximum amount you will have to pay out o
saul85 [17]
Your monthly premium is the payment you make to your car insurance company that keeps your coverage active.

A car insurance deductible is the amount of money you have to pay toward repairs before your insurance covers the rest.

Therefore $700 is the maximum amount you will have to pay
<span>out of pocket for a car accident before your insurance covers your cost.</span>
4 0
3 years ago
How do access the dictionary and thesaurus in Word?
horrorfan [7]
Click the FILE tab. Click Options in the list on the left side of the screen. On the WordOptions dialog box, click Proofing in the list of options on the left. 
3 0
3 years ago
Read 2 more answers
What are the common causes of signal loss in fiber optic cable connectors
timurjin [86]
Bending, twisting, or the overall age of the cable, or other stuff like that.
8 0
3 years ago
Carmina wants to move a paragraph to the right margin of the document she is working in. She moves her cursor to
MissTica

Answer:

Carmina should use Indent option in order to move a paragraph to the right margin of the margin she is working in.

Explanation:

Indents are used basically to display the blank spaces or distance of the paragraph from the left of right margin.

A simple indent moves the paragraph on either left margin side or right margin side as selected. In order to customize the indents:

  • Click on Home tab.
  • Locate Paragraph group.
  • Click on Indents and Spacing.
  • Now under the Indentation option, from the drop down menu name Special, we can choose an indent to be:

                         1. First Line

                         2. Hanging

  • Moreover, length of the indent can be adjusted.

<h3>I hope it will help you!</h3>
4 0
4 years ago
Read 2 more answers
If you don’t have a paper copy of the FAFSA form, how else can you fill it out?
Ronch [10]
Go on your school computer, and find a copy of the form. Then print it from the school printer.
3 0
3 years ago
Read 2 more answers
Other questions:
  • You buy a $3,500 car and finance it through the car dealer. the contract says if you are two months delinquent with your payment
    9·1 answer
  • Which is an example of withholding you might see on your pay stub
    14·2 answers
  • What is the most widely used operating system for mobile devices?
    7·1 answer
  • Define full-duplex. Group of answer choices term used to describe the networking device that enables hosts in a LAN to connect t
    9·1 answer
  • LAB: Count multiples (EO)
    5·1 answer
  • First person to answer gets free brainlist
    15·2 answers
  • Como realizar un cuadro comprativo?​
    13·1 answer
  • In what way can an employee demonstrate commitment?
    15·2 answers
  • Why is computer called information processing machine ?????​
    6·2 answers
  • Assuming a single-processor system, that load and store are atomic, that x is initialized to 0, and that x must be loaded into a
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!