Skip to content

Instantly share code, notes, and snippets.

@nutchy
Created January 23, 2018 05:02
Show Gist options
  • Save nutchy/d9f01698e0ac572ba90611a8f96bb91b to your computer and use it in GitHub Desktop.
Save nutchy/d9f01698e0ac572ba90611a8f96bb91b to your computer and use it in GitHub Desktop.
package countalphabet;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class CountAlphabet {
public static void main(String[] args) {
// TODO code application logic here\
int total_vowel = 0;
System.out.print("Input your String... : ");
Scanner sc = new Scanner(System.in);
String text = sc.nextLine().toLowerCase();
System.out.println(text);
List vowel = new ArrayList<>();
vowel.add('a');
vowel.add('e');
vowel.add('i');
vowel.add('o');
vowel.add('u');
for(char alphabet : text.toCharArray()){
if(vowel.contains(alphabet)){
total_vowel++;
}
}
System.out.println("Total vowel = "+total_vowel);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment