Formatted with Google Java Formatter

This commit is contained in:
github-actions 2021-09-21 18:25:36 +00:00
parent d5a46cb8f3
commit c9c8824685

View File

@ -9,32 +9,34 @@ import java.util.Scanner;
*/ */
public class TurkishToLatinConversion { public class TurkishToLatinConversion {
/** /**
* Main method * Main method
* *
* @param args Command line arguments * @param args Command line arguments
*/ */
public static void main(String args[]) { public static void main(String args[]) {
Scanner sc = new Scanner(System.in); Scanner sc = new Scanner(System.in);
System.out.println("Input the string: "); System.out.println("Input the string: ");
String b = sc.next(); String b = sc.next();
System.out.println("Converted: " + convertTurkishToLatin(b)); System.out.println("Converted: " + convertTurkishToLatin(b));
sc.close(); sc.close();
} }
/** /**
* This method converts a turkish character to latin character. * This method converts a turkish character to latin character.
* *
* @param param String paramter * @param param String paramter
* @return String * @return String
*/ */
public static String convertTurkishToLatin(String param) { public static String convertTurkishToLatin(String param) {
char[] turkishChars = new char[]{0x131, 0x130, 0xFC, 0xDC, 0xF6, 0xD6, 0x15F, 0x15E, 0xE7, 0xC7, 0x11F, 0x11E}; char[] turkishChars =
char[] latinChars = new char[]{'i', 'I', 'u', 'U', 'o', 'O', 's', 'S', 'c', 'C', 'g', 'G'}; new char[] {0x131, 0x130, 0xFC, 0xDC, 0xF6, 0xD6, 0x15F, 0x15E, 0xE7, 0xC7, 0x11F, 0x11E};
for (int i = 0; i < turkishChars.length; i++) { char[] latinChars = new char[] {'i', 'I', 'u', 'U', 'o', 'O', 's', 'S', 'c', 'C', 'g', 'G'};
param = param.replaceAll(new String(new char[]{turkishChars[i]}), new String(new char[]{latinChars[i]})); for (int i = 0; i < turkishChars.length; i++) {
} param =
return param; param.replaceAll(
new String(new char[] {turkishChars[i]}), new String(new char[] {latinChars[i]}));
} }
return param;
}
} }