Advertisement
Flaron

Betumix

Jun 18th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Progmasters {
  4.  
  5. public static void main(String[] args) {
  6.  
  7. Scanner scanner = new Scanner(System.in);
  8. String string1 = scanner.nextLine();
  9. String string2 = scanner.nextLine();
  10.  
  11. if (string1.length()>string2.length()) {
  12. String newString = "";
  13. int i = 0;
  14. while (i<string2.length()){
  15. newString =string2.substring(i, i+1)+string1.substring(i, i+1);
  16.  
  17. System.out.print(newString);
  18. i++;
  19. }
  20. System.out.print(string1.substring(i));
  21. }
  22.  
  23. else {
  24. String newString = "";
  25. int i = 0;
  26. while (i<string1.length()){
  27. newString = string2.substring(i, i+1)+string1.substring(i, i+1);
  28. System.out.print(newString);
  29. i++;
  30. }
  31. System.out.print(string2.substring(i));
  32. }
  33. scanner.close();
  34.  
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement