shivamisone

vowchange

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