/* Define a class to accept two strings of same length and form a new word in such a way that, the first character of the
* first word is followed by the first character of the second word and so on.
* Example - Input: String 1 : BALL
* String 2 : WORD
* Output : BWAOLRLD
*/
import java.util.*;
class QUESTION_7
{
public static void main(String[]args)
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the first string:");
String st=sc.nextLine();
System.out.println("Enter the second string:");
String str=sc.nextLine();
String wrd="";
if(st.length()==str.length())
{
for(int i=0;i<st.length();i++)
{
wrd=wrd+st.charAt(i)+str.charAt(i);
}
System.out.println("Output: "+wrd);
}
else
System.out.println("Both the word should be of same length");
}
}
No comments:
Post a Comment
any problem in any program comment:-