W.A.P to enter the 10 names in the array and print the names in the array which start
with a vowel.
Answers
Answered by
2
import java.util.Scanner;
public class Names {
public static void main(String[ ] args) {
String[ ] names = new String[10];
System.out.println("Enter 10 names - ");
for (int i = 0; i < names.length; i++)
names[i] = new Scanner(System.in).nextLine( );
System.out.println("Displaying names starting with a vowel - ");
for (String name : names)
for (char letter : new char[ ] {'a', 'e', 'i', 'o', 'u'})
if (name.toLowerCase( ).startsWith(letter + "")) {
System.out.print(name + " ");
continue;
}
}
}
Similar questions
Social Sciences,
4 months ago
Computer Science,
4 months ago
Math,
4 months ago
Physics,
9 months ago
History,
1 year ago
Math,
1 year ago