Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javaapplication98;
- import java.util.*;
- /**
- *
- * @author Student
- */
- public class JavaApplication98 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- Scanner scan=new Scanner (System.in);
- System.out.print("Enter Word: ");
- String line = scan.nextLine();
- int vowels = 0, consonants = 0, digits = 0, spaces = 0;
- line = line.toLowerCase();
- for(int i = 0; i < line.length(); ++i){
- char ch = line.charAt(i);
- if(ch == 'a' || ch == 'e' || ch == 'i'
- || ch == 'o' || ch == 'u') {
- ++vowels;
- }
- else if((ch >= 'a'&& ch <= 'z')) {
- ++consonants;
- }
- }
- System.out.println("Vowels: " + vowels);
- System.out.println("Consonants: " + consonants);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement