Sunday, 24 January 2021

program to accept no of sentences from user and also the sentences and print the no of words without vovels and consicutive alphabets in each sentences and print the reverse sentence

import java.io.*;
class abc
{
    public static void main(String args[])throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        System.out.println("entre the number of sentences");
        int n=Integer.parseInt(br.readLine());
        String s1[]=new String[n];
        for(int i=0;i<n;i++)
        {
            System.out.println("entre the "+(i+1)+"sentene");
            s1[i]=br.readLine();
        }
         for(int i=0;i<n;i++)
         {
            String s2="";
            String s3="";
            int c=0;
            int c1=0;
            int c2=0;
            String s="";
            s=s1[i];
            s=s+" ";
            int l=s.length();
            int l2=0;
            for(int j=0;j<l;j++)
            {
                if(s.charAt(j)==' ')
                {
                    for(int k=l2;k<=j;k++)
                    {
                        if(s.charAt(k)=='a'||s.charAt(k)=='e'||s.charAt(k)=='i'||s.charAt(k)=='o'||s.charAt(k)!='u')
                        {
                            c=c+1;
                            break;
                        }
                    }
                    if(c==0)
                    {
                        c1=c1+1;
                    }
                    
                    for(int k=l2;k<j-1;k++)
                     {
                         if(s.charAt(k)==s.charAt(k+1))
                         {
                             c2=c2+1;
                             break;
                            }
                        }
                       for(int k=l2;k<j;k++)
                          {
                              s2=s2+s.charAt(k);
                            }
                       l2=j+1;
                       s3=" "+(s2+s3);
                       s2="";
                       c=0;
                    }
                    
                       
                }
               System.out.println("no of words without vovel in "+i+1+"sentence="+c1);   
                 System.out.println("no of words with consiqutive alphabets in "+i+1+"sentence="+c2);
                  System.out.println(s3);
                }
            }
        }
        



No comments:

Post a Comment

HAY THAKYOU FOE VISIT

Program(python):-Find duplicates in an array (Geeks for geek problem)

QUESTION:- Given an array  a  of size  N  which contains elements from  0  to  N-1 , you need to find all the elements occurring more than o...