import java.util.Scanner;_x000D_
_x000D_
public class Exercise19 {_x000D_
    public static void main(String[] args) {_x000D_
        // INTERLEAVE_x000D_
        Scanner console = new Scanner(System.in);_x000D_
_x000D_
        System.out.print("First string: ");_x000D_
        String first = console.nextLine();_x000D_
_x000D_
        System.out.print("Second string: ");_x000D_
        String second = console.nextLine();_x000D_
_x000D_
        // 1. Write a loop to interleave two strings to form a new string._x000D_
        // To interleave, during each loop take one character from the first string and add it to the result_x000D_
        // and take one character from the second string and add it to the result._x000D_
        // If there are no more characters available, don't add characters._x000D_
        // 2. Print the result._x000D_
        int max = Math.max(first.length(),second.length());_x000D_
        String mix = "";_x000D_
        for (int i = 0; i < max; i++) {_x000D_
            if (i < Math.min(first.length(), second.length())) {_x000D_
                mix += (Character.toString(first.charAt(i)) + Character.toString(second.charAt(i)));_x000D_
                continue;_x000D_
            }_x000D_
            if (first.length() == max){_x000D_
                mix += (Character.toString((first.charAt(i))));_x000D_
            }_x000D_
            if (second.length() == max){_x000D_
                mix += (Character.toString((second.charAt(i))));_x000D_
            }_x000D_
        }_x000D_
        System.out.println(mix);_x000D_
_x000D_
        // Examples_x000D_
        // "abc", "123" -> "a1b2c3"_x000D_
        // "cat", "dog" -> "cdaotg"_x000D_
        // "wonder", "o" -> "woonder"_x000D_
        // "B", "igstar" -> "Bigstar"_x000D_
        // "", "huh?" -> "huh?"_x000D_
        // "wha?", "" -> "wha?"_x000D_
    }_x000D_
}_x000D_

// "wonder", "o" -> "woonder"_x000D_
import java.util.Scanner;_x000D_
_x000D_
public class Exercise19 {_x000D_
    public static void main(String[] args) {_x000D_
        // INTERLEAVE_x000D_
        Scanner console = new Scanner(System.in);_x000D_
_x000D_
        System.out.print("First string: ");_x000D_
        String first = console.nextLine();_x000D_
_x000D_
        System.out.print("Second string: ");_x000D_
        String second = console.nextLine();_x000D_
_x000D_
        // 1. Write a loop to interleave two strings to form a new string._x000D_
        // To interleave, during each loop take one character from the first string and add it to the result_x000D_
        // and take one character from the second string and add it to the result._x000D_
        // If there are no more characters available, don't add characters._x000D_
        // 2. Print the result._x000D_
        int max = Math.max(first.length(),second.length());_x000D_
        String mix = "";_x000D_
        for (int i = 0; i < max; i++) {_x000D_
            if (i < Math.min(first.length(), second.length())) {_x000D_
                mix += (Character.toString(first.charAt(i)) + Character.toString(second.charAt(i)));_x000D_
                continue;_x000D_
            }_x000D_
            if (first.length() == max){_x000D_
                mix += (Character.toString((first.charAt(i))));_x000D_
            }_x000D_
            if (second.length() == max){_x000D_
                mix += (Character.toString((second.charAt(i))));_x000D_
            }_x000D_
        }_x000D_
        System.out.println(mix);_x000D_
_x000D_
        // Examples_x000D_
        // "abc", "123" -> "a1b2c3"_x000D_
        // "cat", "dog" -> "cdaotg"_x000D_
        // "wonder", "o"<SUF>
        // "B", "igstar" -> "Bigstar"_x000D_
        // "", "huh?" -> "huh?"_x000D_
        // "wha?", "" -> "wha?"_x000D_
    }_x000D_
}_x000D_
