Created
October 19, 2017 00:53
-
-
Save ClassCubeGists/237a20de112c5e94e0a213ed42ebf578 to your computer and use it in GitHub Desktop.
Solution for problem on ClassCube Moodle demo site https://moodle.classcube.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.*; | |
public class VowelCounter { | |
public static void main( String[] args ) { | |
// Your code goes here... | |
int cnt = 0; | |
try { | |
Scanner f = new Scanner(new File("words.dat")); | |
while (f.hasNext()) { | |
for(String s:f.next().split("")) { | |
if (s.matches("[aeiou]")) { | |
cnt++; | |
} | |
} | |
} | |
System.out.println(cnt); | |
} | |
catch (Exception e) { | |
System.out.println("Cannot find file"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment