Reverse of a String and Number of Vowels - Java Program - Scanner


Reverse of a String and Number of Vowels  
 Scanner -Java Program
Program: Reverse.java
import java.util.Scanner;
class Reverse 
{
public static void main(String args[])
{
 String string,reverseString = "";
 int vowelCount=0;
 
   Scanner sc=new Scanner(System.in);
   System.out.print("Enter the word: ");
   string= sc.nextLine();
   
   for(int i=string.length()-1;i>=0;i--)
   {
    char ch=string.charAt(i);
    reverseString+=ch;
    if(ch=='A'||ch=='a'||ch=='E'||ch=='e'||ch=='I'||ch=='i'||ch=='O'||ch=='o'||ch=='U'||ch=='u')
    vowelCount++;
   }
   
   
   System.out.println("Reverse: "+reverseString+"\nNumber of vowels: "+vowelCount);
   
}
}

Output:
Enter the word: 2k8cse
Reverse: esc8k2
Number of vowels: 1

7 comments:

  1. Your site has a lot of useful information for myself. I visit regularly. Hope to have more quality items.

    ReplyDelete
  2. Looking forward to reading more.. Great post. Really Cool
    gmail login

    ReplyDelete
  3. in a multidimensional array (say a 2-dimensional array) containing many real numbers (both negative and positive), what do I need to do to be able to sort it in a certain dimension? (e.g. ascending or descending numeric values)
    thanks!

    ReplyDelete
  4. This blog provides readers with valuable information. The writing style makes it enjoyable to read. Thanks for creating such a useful resource.servicenow online training

    ReplyDelete
  5. Great article! Businesses looking to strengthen their online presence can benefit from professional Digital Marketing Services that drive measurable results and long-term growth.

    ReplyDelete
  6. Thanks for sharing these valuable insights. Reliable online marketing services help businesses reach the right audience and increase brand visibility effectively.

    ReplyDelete

Related Posts Plugin for WordPress, Blogger...