Computer Science, asked by riya31jan, 11 months ago

plz...yrr...help me out..!!!
question no 9...solve it

Attachments:

riya31jan: jamshedpur
siddhartharao77: Please..dont disturb

Answers

Answered by siddhartharao77
4

Sample Program to Count Frequency of vowels in a string:

import java. util. *;

class Brainly

{

public static void main(String args[])

{

int a=0,e=0,i=0,o=0,u=0,Sum;

String S;

char c;

Scanner demo = new Scanner(System. in);

System. out. println("Enter String :");

S = demo. nextLine();

S = S. toUpperCase();

Sum = S. length();

for(i = 1; i < Sum; i++)

{

c = S. charAt(i);

if(c=='A')

a=a+1;

if(c=='E')

e=e+1;

if(c=='I')

i=i+1;

if(c=='O')

o=o+1;

if(c=='U')

u=u+1;

}

System. out. println("Frequency of A: "+a);

System. out. println("Frequency of E: "+e);

System. out. println("Frequency of I: "+i);

System. out. println("Frequency of O: "+o);

System. out. println("Frequency of U: "+u);

}

}


Output:

Enter String: RAIN WATER HARVESTING ORGANISED BY UNESCO.

Frequency of A : 4

Frequency of E : 4

Frequency of I : 3

Frequency of O : 2

Frequency of U : 1


<!Hope it helps!

Attachments:
Similar questions