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
A keyboard, mouse, and microphone are examples of ________.
kykrilka [37]

Answer:

A keyboard, mouse, and microphone all are examples of <u>peripheral devices.</u>

Explanation:

hope this helps

5 0
2 years ago
Read 2 more answers
Who wrote the book of luke​
netineya [11]
Luke himself wrote t the book
5 0
2 years ago
How do you play ps2 discs on a ps3 console
ExtremeBDS [4]
Look at the serial number. Find the sticker on the back of your PS3. The last digits will inform you as to whether you have full hardware backwards compatibility, or limited software emulation:
CECHAxx (60 GB) and CECHBxx (20 GB) - Full hardware backwards compatibility.
CECHCxx (60 GB) and CECHExx (80 GB) - Limited hardware emulation (These models do not contain the Emotion Engine, as it is instead emulated by the Cell processor). You may run into issues with some PS2 discs.
CECHGxx and above - These models are not backwards compatible.
8 0
2 years ago
Suppose that a queue is implemented using a circular array of size 12. What is the value of last after the following operations?
otez555 [7]

Answer:

10

Explanation:

An enqueue operation is a function that adds an element(value) to a queue array. A dequeue operations removes an element from a queue array. Queue arrays follow a first-in-first-out approach, so elements that are first stored in the queue are removed/accessed first(enqueue operations add elements at the rear of the queue array).

The following operations leave 10 elements in the queue of array size 12 after its done:

10 enqueue operations= adds 10 elements

5 dequeue operations= removes 5 elements( 5 elements left in queue)

6 enqueue operations= adds 6 elements(11 elements in queue)

10 dequeue operations= removes 10 elements(1 element left in queue)

8 enqueue operations= adds 8 elements(9 elements in queue)

2 dequeue operations= removes 2 elements(7 elements left in queue)

3 enqueue operations= adds 3 elements(10 elements in queue)

Therefore there are 10 elements in the queue after enqueue and dequeue operations.

8 0
3 years ago
Match the following technologies with their applications.
kap26 [50]

Answer:

3d printing

Explanation:

7 0
3 years ago
Other questions:
  • How many homes can be warmed by one bugatti
    11·2 answers
  • If you were given a 3D microscope to use for photography, which object(s) would you most want to photograph?
    10·2 answers
  • Which situation is an example of? "relational context" in the transactional model of? communication?
    12·1 answer
  • Renee is creating a multimedia presentation for a website that requires user interaction. Which multimedia type is Renee using?
    5·2 answers
  • Write a method reverse( ) for OurLinkedList class. The method should return a new OurLinkedList object that is the reverse of th
    8·1 answer
  • What is the purpose of the .NET Framework Class Library? a. it provides pre-written code that can be used by .NET applications b
    13·1 answer
  • Write a program that asks the user to input
    11·1 answer
  • 2. Write a Python regular expression to replace all white space with # in given string “Python is very simple programming langua
    14·1 answer
  • Compare mini and mainframe computer in terms of speed,memory and storage​
    15·1 answer
  • It specifies the amount of memory needed to store data.
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!