//please save this code as Countvowel.java or download the given file and compile it with " javac Countvowel.java " //After successful compilation run this with " java Countvowel" at CMD // Make sure you have java already //installed in your system . use Notepad ++ CODE : : import java.util.*; class Countvowel { public static int a,e,i,o,u; public static void main(String m[]) { Scanner in=new Scanner(System.in); String s=new String(); while(true) { int ta=0,te=0,ti=0,to=0,tu=0; System.out.println("Enter A line :"); s=in.nextLine(); if(s.equals("quit")) { break; } else { int n=s.length()-1; for(int x=0;x<=n;x++) { switch(s.charAt(x)) { case 'a' : case 'A' : a++; ta++; break; case 'e' : case 'E' : e++; te++;break; case 'i' : case 'I' : i++; ti++; break; case 'o' : case 'O' : o++; to++; break; case 'u' : case 'U' : u++; tu++; break; } } System.out.println("\n\n In this statement:"); System.out.println("a comes: "+ta+" times"); System.out.println("e comes :"+te+" times"); System.out.println("i comes :"+ti+" times"); System.out.println("o comes: "+to+" times"); System.out.println("u comes :"+tu+" times"); } } System.out.println("\n\n Totle numbers of the vovels::"); System.out.println("a comes "+a+" times"); System.out.println("e comes "+e+" times"); System.out.println("i comes "+i+" times"); System.out.println("o comes "+o+" times"); System.out.println("u comes "+u+" times"); } } OUTPUT : :
DARSHIT
7/1/2019 09:39:44 am
your is helpful us.
Reply
Vrajesh
29/6/2019 05:21:22 pm
I think Question is "Program continue until we write sentence QUIT" but their no coding for that portion...
Reply
Your comment will be posted after it is approved.
Leave a Reply. |
Hello friends, i am a CSE student and i am going to upload all the programs of various language which might be in your collage practical list or might help you in performing your practicals in lab. Archives
August 2015
Categories |