Computer Science, asked by Ayojoe3317, 10 months ago

Write a program to count the vowels in a string.

Answers

Answered by nain31
6

 \huge \boxed{CODING}

import java. util. *;

class vowel

{

public static void main(String args[])throws Exception

{

Scanner sc=new Scanner(Sys tem . in);

String s;

int i ,ctr;

char ch;

System . out . println("Enter any word");

s=in . next();

s=s . toUpperCase();

for(i=0 ;i<s . length() ;i++)

{

ch= s. charAt(i);

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

ctr ++ ;

}

System . out. println("Number of vowels are" + ctr);

}

}

 \huge \boxed{OUT PUT}

s= hello

 \huge \boxed{Number \: of \: vowels \:are  \: 2}

Similar questions