Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class vowels {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- String word;
- word = TextIO.getWord(); //accept input as word
- char numberOfVowels = 'a', 'e', 'i', 'o', 'u';
- int sizeOfWord = word.length(); //it returns the TOTAL # of characters in the String value
- //an integer value is returned
- int endPosition = sizeOfWord - 1;
- int loopCounter = 0;
- int matches = 0;
- //Loop starts at 0 and then ends at "endPosition"
- //starts at 0 and go as long as the value is less than or equal to endPosition
- while(loopCounter <= endPosition; word != "xxxx" || "XXXX")
- {
- //examine each letter in the word
- if(word.charAt(loopCounter) == numberOfVowels)
- matches = matches + 1; //one match found
- loopCounter = loopCounter + 1;
- System.out.println(word + " has " + numberOfVowels + " vowels in total");
- if(word == "xxxx" || "XXXX")
- System.out.println("You quit!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement