Computer Science, asked by shivajisingh0111, 8 months ago

Was in Java to enter a sentence and print the word have maximum number of vowels. Sample input : INDIA IS GREAT Sample output : word with maximum number of vowels : 3)​

Answers

Answered by ʙᴇᴀᴜᴛʏᴀɴɢᴇʟ
10

Explanation:

Write a program to input a sentence and print the words which contains maximum number of vowels

example : input: India is my country

output: INDIA

import java.io.*;

public class HighestVowel

{ // start of class

static void main()throws IOException

{ //start of main ()

InputStreamReader isr= new InputStreamReader(System.in);

BufferedReader br= new BufferedReader(isr);

System.out.print("Enter a String= ");

String s=br.readLine();

String s1,s2="";

s=s+" ";

s=s.toUpperCase();

int n=s.length();

int i,j,m,p=0;

int countvowel=0,totalvowel=0;

char ch;

for(i=0;i<n;i++)

{ //start of loop i for main string

if(s.charAt(i)==' ')

{ //start of if for space

s1="";

countvowel=0;

s1=s.substring(p,i);

p=i+1;

m=s1.length();

for(j=0;j<m;j++)

{ // start of loop j for substring

ch=s1.charAt(j);

if(ch=='A' || ch=='E' || ch=='I'|| ch=='O'|| ch=='U')

{ //start of if for counting the number vowel in substring

countvowel++;

} //end of if for counting the number vowel in substring

} // end of loop j for substring

if(totalvowel<countvowel)

{ //start of if for checking maximum number of vowel

s2=s1;

totalvowel=countvowel;

} //end of if for checking maximum number of vowel

} //end of if for space

} //end of loop i for main string

System.out.print("The word with maximum number of vowel is: "+s2);

} //end of main ()

} // end of class

Answered by Anmolabd
5

Answer:

I can not answer this....m

Similar questions