Skip to content

Instantly share code, notes, and snippets.

@annibuliful
Created January 29, 2018 18:07
Show Gist options
  • Save annibuliful/71b4f0aeca31f682b4c9be9696a6d3cc to your computer and use it in GitHub Desktop.
Save annibuliful/71b4f0aeca31f682b4c9be9696a6d3cc to your computer and use it in GitHub Desktop.
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