-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTestZohoVowels.java
More file actions
40 lines (33 loc) · 1.17 KB
/
TestZohoVowels.java
File metadata and controls
40 lines (33 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.gokul.matrix;
public class TestZohoVowels {
public static void main(String[] args) {
char[] charArray={'G','O','O','d',' ','m','O','r','n','I','n','g'};
checkNonConsecutiveVowels(charArray);
}
public static void checkNonConsecutiveVowels(char[] charArray){
int count=0; boolean flag=false;
for(int i=0;i<charArray.length;i++){
if(charArray[i]=='A')
charArray[i]='a';
else if(charArray[i]=='E')
charArray[i]='e';
else if(charArray[i]=='I')
charArray[i]='i';
else if(charArray[i]=='O')
charArray[i]='o';
else if(charArray[i]=='U')
charArray[i]='u';
}
for(int i=1;i<charArray.length-1;i++){
if((charArray[i+1]!='a' && charArray[i+1]!='e' && charArray[i+1]!='i' && charArray[i+1]!='o' && charArray[i+1]!='u')
&& (charArray[i-1]!='a' && charArray[i-1]!='e' && charArray[i-1]!='i' && charArray[i-1]!='o' && charArray[i-1]!='u'))
{
if((charArray[i]=='a' || charArray[i]=='e' || charArray[i]=='i' || charArray[i]=='o' || charArray[i]=='u'))
count++;
}
}
System.out.println("Number of Non consecutive vowels are "+count);
}
}
//output
//Number of Non consecutive vowels are 2