Created
January 29, 2018 18:07
-
-
Save annibuliful/71b4f0aeca31f682b4c9be9696a6d3cc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class ChangeFormate { | |
@SuppressWarnings({ "resource", "unused" }) | |
public static void main(String[] args) { | |
String[] storeOutput; | |
Scanner input = new Scanner(System.in); | |
String charInput = input.next(); | |
String formatInput = input.next(); | |
int IndexOfchar = 0; | |
int IndexOfFormat = 0; | |
int lastIndexOfChar = charInput.length(); | |
while(IndexOfchar <= lastIndexOfChar) { | |
if(IndexOfchar != lastIndexOfChar) { | |
if (formatInput.charAt(IndexOfFormat) == 'x' || formatInput.charAt(IndexOfFormat) == 'X') { | |
System.out.print(charInput.charAt(IndexOfchar)); | |
IndexOfchar++; | |
IndexOfFormat++; | |
} else { | |
System.out.print("-"); | |
IndexOfFormat++; | |
} | |
} else { | |
break; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment