shivamisone

revvow

Aug 9th, 2023
924
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | Source Code | 0 0
  1. import java.util.*;
  2. public class rev{
  3.     static String newrds = "";
  4.     static String wrds;
  5.     public static void main(){
  6.         rev ob = new rev();
  7.         ob.acceptword();
  8.         ob.freqvowcont();
  9.         ob.nextVowel();
  10.         ob.disp();
  11.     }
  12.     void acceptword(){
  13.         Scanner sc = new Scanner(System.in);
  14.         wrds = sc.nextLine();
  15.         wrds = wrds.toUpperCase();
  16.     }
  17.     void freqvowcont(){
  18.         int c = 0;
  19.         for(int i =0; i< wrds.length();i++){
  20.             char ch = wrds.charAt(i);
  21.             if(ch =='A'||ch =='E'||ch =='O'||ch =='I'||ch =='U'){
  22.                 c++;
  23.             }
  24.         }
  25.         System.out.println("vowels:"+c+" consonants"+(wrds.length()-c));
  26.     }
  27.     void nextVowel(){
  28.         int len = wrds.length();
  29.         for(int i =0;i<len;i++){
  30.             char ch = wrds.charAt(i);
  31.             if(ch =='A'||ch =='E'||ch =='O'||ch =='I'||ch =='U'){
  32.                 newrds = ch+newrds;
  33.             }
  34.             else{
  35.                 newrds = newrds+ch;
  36.             }
  37.         }
  38.     }
  39.     void disp(){
  40.         System.out.println(newrds);
  41.         newrds ="";
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment