Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Midterm2
- {
- public static void main (String[] args)
- {
- String phrase;
- int vowels = 0;
- int consonants = 0;
- int position = 0;
- char ch;
- Scanner input = new Scanner(System.in);
- phrase = input.nextLine();
- phrase = phrase.toLowerCase();
- for (position = 0 ; position < phrase.length(); position++)
- {
- ch = phrase.charAt(position);
- if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u')
- {
- vowels++;
- }
- else
- {
- consonants++;
- }
- }
- System.out.println(phrase + " has " + vowels + " vowels and " + consonants + " consonants.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement