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 scanner = new Scanner(System.in);
- System.out.println("Enter a sentence:");
- String line = scanner.nextLine();
- int count = 0;
- for (int i = 0; i < line.length(); i++) {
- if ('a' == line.charAt(i)
- || 'o' == line.charAt(i)
- || 'u' == line.charAt(i)
- || 'e' == line.charAt(i)
- || 'i' == line.charAt(i)
- || 'y' == line.charAt(i)) {
- count++;
- }
- }
- System.out.println("The number of vowels is " + count);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement