Computer Science, asked by ansari9263, 9 months ago

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 Oreki
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