Tuesday, March 23, 2010

Enter String-Find No of Vowels,Chars,Reverse String

import java.io.*;
public class reverse
{ public static void main(String args[]) throws IOException
  {  
  InputStreamReader read = new InputStreamReader(System.in);
  BufferedReader br = new BufferedReader(read);
   
  System.out.println("Enter string(uppercase)");
  String s=br.readLine();
   
  s = s.toUpperCase();
  StringBuffer revs = new StringBuffer(s);
  int ch = revs.length();
  int vow = 0;
  for(int i=0;i  { if(revs.charAt(i)=='A' || revs.charAt(i)=='E' || revs.charAt(i)=='I' || revs.charAt(i)=='O' || revs.charAt(i)=='U')
  {vow++;}
  }

  revs.reverse();
  System.out.println("Total number of characters: " +ch);
  System.out.println("Number of vowels: "+vow);
  System.out.println("Reverse String: "+revs);
  }
}
   

   

No comments:

Post a Comment