top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Write a program which accepts 2 strings from the user and performs the following operation on it?

+1 vote
109 views

Write a program which accepts 2 strings from the user and performs the following operation on it.
Example –
string1 = “Hello”
string2 = “World”
string3 must be “HellodlroW”

Both strings must be concatenated but after reversing the second string (as shown in string3 above).

posted May 14, 2017 by Azhar Keer

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

1 Answer

+1 vote

public class StringConcatTest {

/**
 * @param args
 */
public static void main(String[] args) {

    Scanner sc=new Scanner(System.in);
    System.out.println("Enter two Strings");
    String s1=sc.nextLine();
    String s2=sc.nextLine();

    String s3=new StringBuilder(s1).append(new StringBuilder(s2).reverse()).toString();
    System.out.println(s3);

}

}

answer May 25, 2017 by S Santhosh
i need c code for this program
Similar Questions
+2 votes

Input:
arr = {'a', 'b'}, length = 3

Output:
aaa
aab
aba
abb
baa
bab
bba
bbb

+2 votes

Given 2 strings, a and b, return a string of the form shorterString+longerString+shorterString, with the shorter string on the outside and the longer string on the inside. The strings will not be the same length, but they may be empty (length 0). If input is "hi" and "hello", then output will be "hihellohi".

0 votes

Inputs would be:
- Name
- age
- gender
- married/unmarried

User feeds this data once but he/she can check later on also. So in this case program should have option to feed and read data from file.

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...