Professional Documents
Culture Documents
Program Write A Program To Accept A String and Output The Word Having The Maximum No. of Vowels in It. Algorithm
Program Write A Program To Accept A String and Output The Word Having The Maximum No. of Vowels in It. Algorithm
Write a program to accept a string and output the word having the
maximum no. of vowels in it.
ALGORITHM :-
STEP 1:- START
Initialize max=0,a=0,i=0,j=0
Assign ar=str.charAt(j)
Check ar==A||ar==E||ar==I||ar==O||ar==U||ar==a||ar==e||ar==i||ar==o||
ar==u then
Increment c++
CODING:-
class word
{ void accept(String s)
{ int max=0,a=0,l,i,c,len,j;
for(i=0;i<l;i++)
{ c=0;
String str=sr[i];
for(j=0;j<len;j++)
a=i;
}}
}}
OUTPUT:-
Input-switzerland is a beautiful place
PROGRAM
Write a program to accept a string and a substring and output the
no. of occurrence of the given substring in the main string.
ALGORITHM :-
STEP 1:- START
Increment c++
CODING:-
class find
l=str.length;
for(i=0;i<l;i++)
{ if(str[i].equals(sr))
c++;
}}
OUTPUT:-
Input- String :- defeat the defeat before defeat defeats you
Substring :- defeat
Result- Occurence of substring defeat in string defeat the defeat before defeat
defeats you is 3 times
PROGRAM
Write a program to accept 50 no. within the method itself and print
the following:
No. of positive values
No. of negative values
No. of odd values
No. of even values
No. of zeros
ALGORITHM :-
STEP 1:- START
STEP 2:- Declare i. Initialize a[50], pos=0, neg=0, even =0, odd=0, zero=0
Input a[i]
Increment i++
Increment pos++
Otherwise neg++
Increment i++
Increment even++
Otherwise odd ++
Increment i++
Increment zero++
Increment i++
CODING:-
import java.io.*;
class number
for(i=0;i<50;i++)
{ a[i]=Integer.parseInt(d.readLine());
for(i=0;i<50;i++)
{ if(a[i]>0)
pos++;
else
neg++;
for(i=0;i<50;i++)
{ if(a[i]%2==0)
even++;
else
odd++;
for(i=0;i<50;i++)
{ if(a[i]==0)
zero++;
}}
OUTPUT:-
Input- Enter 50 numbers
23 23 87 66 72
45 56 -9 0 -66
-89 0 78 -56 77
67 -53 0 -52 22
-34 1 -40 45 0
0 77 34 43 2
56 -97 88 -44 -4
21 0 10 81 7
-67 85 -23 90 3
0 43 67 2 -18
Result:-