```
import java.util.Scanner;
public class AddAnArticle {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a sentence: ");
String sentence = scanner.nextLine();
String[] words = sentence.split("\\s+");
for (int i = 0; i < words.length; i++) {
if (isVowel(words[i].charAt(0))) {
words[i] = "an " + words[i];
} else if (isCapitalVowel(words[i].charAt(0))) {
words[i] = "An " + words[i].substring(1);
}
}
String newSentence = String.join(" ", words);
System.out.println("New Sentence: " + newSentence);
scanner.close();
}
public static boolean isVowel(char c) {
String vowels = "aeiou";
return vowels.indexOf(Character.toLowerCase(c)) != -1;
}
public static boolean isCapitalVowel(char c) {
String vowels = "AEIOU";
return vowels.indexOf(c) != -1;
}
}
```
```
```
import java.util.Scanner;
public class AddAnArticle {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a sentence: ");
String sentence = scanner.nextLine();
String[] words = sentence.split("\\s+");
StringBuilder newSentence = new StringBuilder();
for (int i = 0; i < words.length; i++) {
if ("aeiouAEIOU".indexOf(words[i].charAt(0)) != -1) {
if (i == 0) {
newSentence.append("An ").append(words[i]);
} else {
newSentence.append(" an ").append(words[i]);
}
} else {
newSentence.append(" ").append(words[i]);
}
}
System.out.println("New Sentence: " + newSentence.toString().trim());
scanner.close();
}
}
```