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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!