Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Vowels {
- public static void main(String[] args) {
- Scanner console = new Scanner(System.in);
- String sentence = console.nextLine();
- String vowels = "aiueoAIUEO";
- int vCount = 0;
- for (int i = 0; i < sentence.length(); i++) {
- char current = sentence.charAt(i);
- if (vowels.indexOf(current) != -1){
- vCount++;
- }
- }
- System.out.printf("There are %d vowels in this sentence.", vCount);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement