Advertisement
wadkat

java vowel counter

Nov 16th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.35 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package javaapplication4;
  7. import java.util.Scanner;
  8. /**
  9.  *
  10.  * @author pclab
  11.  */  
  12. public class JavaApplication4 {
  13.  
  14.     /**
  15.      * @param args the command line arguments
  16.      */
  17.     public static void main(String[] args) {
  18.     Scanner kb = new Scanner(System.in);
  19.     String line;
  20.     char read;
  21.     int v=0, nv=0, len,i;
  22.     System.out.println("Enter any word ");
  23.     line=kb.nextLine();
  24.     len=line.length();
  25.     for(i=0;i<line.length();i++)
  26.     {
  27.     switch(line.charAt(i))
  28.     {case 'a':
  29.         case'A':
  30.             case'e':
  31.                 case'E':
  32.                     case'i':
  33.                         case'I':
  34.                             case'o':
  35.                                 case'O':
  36.                                     case'u':
  37.                                         case'U':
  38.                                             v++;
  39.                                             break;
  40.                                         default:
  41.                                             nv++;
  42.                                            
  43.     }
  44.     }
  45.     System.out.println("Vowels "+v);
  46.     System.out.println("NVowels "+nv);
  47.    
  48.  
  49.     }
  50.    
  51.    
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement