Run
public class Main {
static int isVowel(char ch) {
ch = Character.toUpperCase(ch);
if (ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U')
return 1;
else
return 0;
}
// to count total number of vowel from 0 to n
static int countVowels(String str, int n) {
if (n == 1) return isVowel(str.charAt(n - 1));
return countVowels(str, n - 1) + isVowel(str.charAt(n - 1));
}
// Main Calling Function
public
static void main(String args[]) {
// string object
String str = "prepinsta";
// Total numbers of Vowel
System.out.print("Total number of Vowel = ");
System.out.println(countVowels(str, str.length()));
}
}
public class Noofvowels {
public static void main(String arg[]) {
String s = “Lalit”;
int count = 0;
for(int i=0;i<s.length();i++) {
char c= s.charAt(i);
c=Character.toUpperCase(c);
if(c=='A'||c=='E'||c=='I'||c=='O'||c=='U') {
count++;
}
}
System.out.println(count);
}
}
Hey there, Thanks for commenting, kindly join our Discord server, our mentors will guide you further precisely will all your queries.?
import java.util.Scanner;
class HelloWorld1 {
public static void main(String[] args) {
// MeGhAnA
// mEgHaNa
Scanner sc=new Scanner(System.in);
String str=sc.next();//apple
char[] ch =str.toCharArray();
int count=0;
for(int j=0;j<str.length();j++){
if(isVowel(ch[j])){
count++;
}
}
System.out.println(count);
}
public static boolean isVowel(char ch){
return (ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'||ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U');
}
}