Define a class to accept a string and print the same in reverse, also print the number of vowels in the string.   
        

Eg :S =“BEAUTIFUL”

Output — “LUFITUAEB”
No. of vowels = 5
Solution:
 Define a class to accept a string and print the same in reverse, also print the number of vowels in the string.Eg :S =“BEAUTIFUL”
 

import java.util.*;
class Reverse
{
public static void main (String args[])
{
    Scanner sc = new Scanner(System.in);
    System.out.println("Enter a word in upperCase");
    String s = sc.nextLine();
    
    s=s.toUpperCase();
    
    String rev="";
    int count=0;
    for(int i=0; i< s.length(); i++)
    {
        char ch=s.charAt(i);
        rev = ch + rev;
        
        if(ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')
        count++;
    }
    
    System.out.println(rev);
    System.out.println("No. 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