Question
I keep getting this error, error: cannot find symbol if(num== length) import java.util.*; public class Vowels { public static int countVowels(String s, int num, int
I keep getting this error,
error: cannot find symbol if(num== length)
import java.util.*; public class Vowels { public static int countVowels(String s, int num, int count) { int lenght= s.length(); if(num==length) return count; else { if (s.charAt(num)=='a'||s.charAt(num)=='A'|| s.charAt(num)=='e'||s.charAt(num)=='E'|| s.charAt(num)=='i'||s.charAt(num)=='I'|| s.charAt(num)=='o'||s.charAt(num)=='O'|| s.charAt(num)=='u'||s.charAt(num)=='U') count++; return countVowels(s,num+1,count); } } public static void main(String[]args) { String str; Scanner sc= new Scanner(System.in); System.out.println("check number of vowels:"); str=sc.nextLine(); int result,n=0,cnt=0; result=countVowels(str,n,cnt); System.out.println("Number of vowels"+result);} }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started