Biblioteca Java - Blame information for rev 39
Subversion Repositories:
Rev | Author | Line No. | Line |
---|---|---|---|
39 | mihai | 1 | package introducere.java.controlflow; |
4 | mihai | 2 | |
3 | |||
4 | public class SwitchStructure { | ||
5 | |||
6 | static int countVowel(String word){ | ||
7 | int vcount=0; | ||
8 | int ccount=0; | ||
9 | for(int i=0;i<word.length();i++){ | ||
10 | char c = word.charAt(i); | ||
11 | |||
12 | switch(c) { | ||
13 | case 'a': vcount++;break; | ||
14 | case 'e': vcount++;break; | ||
15 | case 'i': vcount++;break; | ||
16 | case 'o': vcount++;break; | ||
17 | case 'u': vcount++;break; | ||
18 | default : ccount++; | ||
19 | } | ||
20 | } | ||
21 | return vcount; | ||
22 | } | ||
23 | |||
24 | |||
25 | public static void main(String[] args) { | ||
26 | String testword="java"; | ||
27 | System.out.println("Count vowel in word:"+testword+" = "+countVowel(testword)); | ||
28 | |||
29 | testword="expression"; | ||
30 | System.out.println("Count vowel in word:"+testword+" = "+countVowel(testword)); | ||
31 | |||
32 | } | ||
33 | } |