Yorumlar
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (true) {
System.out.print("Enter a text: ");
String input = sc.nextLine();
String output = convertText(input);
System.out.println("Converted: " + output);
}
}
public static String convertText(String text) {
String[] words = text.split(" ");
StringBuilder sb = new StringBuilder();
for (int i = 0; i < words.length; i++) {
String word = words[i];
if (word.length() > 1 && word.charAt(1) == 'a') {
word = word.substring(0, 1) + 'A' + word.substring(2);
}
sb.append(word);
if (i < words.length - 1) {
sb.append(" ");
}
}
return sb.toString();
}
}