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






Cantilever Gate
ReplyDeleteYour site has a lot of useful information for myself. I visit regularly. Hope to have more quality items.
ReplyDeleteLooking forward to reading more.. Great post. Really Cool
ReplyDeletegmail login
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)
ReplyDeletethanks!