Advertisement
Flaron

ProgMasters 10 - Mix together

Jun 18th, 2019
72
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.*;
  2.  
  3. public class Main {
  4. public static void main(String[] args) {
  5.  
  6. Scanner scanner = new Scanner(System.in);
  7.  
  8.  
  9. String string1 = scanner.nextLine();
  10.  
  11. String string2 = scanner.nextLine();
  12.  
  13.  
  14. if (string1.length()>string2.length()) {
  15.  
  16. String newString = "";
  17. int i = 0;
  18. while (i<string2.length()){
  19. newString =string2.substring(i, i+1)+string1.substring(i, i+1);
  20.  
  21. System.out.print(newString);
  22. i++;
  23. }
  24.  
  25. System.out.print(string1.substring(i));
  26.  
  27. }
  28.  
  29. else {
  30. String newString = "";
  31. int i = 0;
  32. while (i<string1.length()){
  33. newString = string2.substring(i, i+1)+string1.substring(i, i+1);
  34.  
  35. System.out.print(newString);
  36. i++;
  37. }
  38.  
  39. System.out.print(string2.substring(i));
  40.  
  41. }
  42. scanner.close();
  43.  
  44.  
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement