Define a class to accept a string and convert it into uppercase. Count and display the
number of vowels in it.
Input: robotics
Output: ROBOTICS
Number of vowels: 3
        
Solution:
,
 


  
import java.util.*;
class Vow 
{
  public static void main(String args[]) 
  {
      String str;int count=0;
      Scanner sc = new Scanner(System.in);
      System.out.println("Enter the word:");
      str = sc.next();
      str=str.toUpperCase();
      System.out.println("Output:"+str);
      for(int i=0;i< str.length();i++)
      {
          char c=str.charAt(i);

          if(c=='A'||c=='E'||c=='I'||c=='O'||c=='U')
          {
              count+=1;
              
          }
      }
      System.out.println("Number of Vowels:"+count);
  }
}
  
                                                           
                                                                  


                                            



Contact Us

REACH US

SERVICES

  • CODING
  • ON-LINE PREPARATION
  • JAVA & PYTHON

ADDRESS

B-54, Krishna Bhawan, Parag Narain Road, Near Butler Palace Colony Lucknow
Contact:+ 919839520987
Email:info@alexsir.com