Advertisement
Guest User

Vowel Counter

a guest
Feb 19th, 2020
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.54 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Vowels {
  4.     public static void main(String[] args) {
  5.         Scanner console = new Scanner(System.in);
  6.  
  7.         String sentence = console.nextLine();
  8.         String vowels = "aiueoAIUEO";
  9.         int vCount = 0;
  10.  
  11.  
  12.         for (int i = 0; i < sentence.length(); i++) {
  13.             char current = sentence.charAt(i);
  14.            if (vowels.indexOf(current) != -1){
  15.                vCount++;
  16.            }
  17.         }
  18.  
  19.         System.out.printf("There are %d vowels in this sentence.", vCount);
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement