Skip to content

Instantly share code, notes, and snippets.

@ClassCubeGists
Created October 19, 2017 00:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ClassCubeGists/237a20de112c5e94e0a213ed42ebf578 to your computer and use it in GitHub Desktop.
Save ClassCubeGists/237a20de112c5e94e0a213ed42ebf578 to your computer and use it in GitHub Desktop.
Solution for problem on ClassCube Moodle demo site https://moodle.classcube.com
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