Advertisement
oona

vowels (don't even try this in computer science though!)

Jan 24th, 2014
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1. public class vowels {
  2.     public static void main(String[] args) {
  3.  // TODO Auto-generated method stub
  4.  
  5.  String word;
  6.  word = TextIO.getWord(); //accept input as word
  7.  
  8.  char numberOfVowels = 'a', 'e', 'i', 'o', 'u';
  9.  int sizeOfWord = word.length(); //it returns the TOTAL # of characters in the String value
  10.          
  11. //an integer value is returned
  12.  
  13. int endPosition = sizeOfWord - 1;
  14.  int loopCounter = 0;
  15.  int matches = 0;
  16.  
  17.  //Loop starts at 0 and then ends at "endPosition"
  18.  //starts at 0 and go as long as the value is less than or equal to endPosition
  19.  while(loopCounter <= endPosition; word != "xxxx" || "XXXX")
  20.  {
  21.   //examine each letter in the word
  22.   if(word.charAt(loopCounter) == numberOfVowels)
  23.    matches = matches + 1; //one match found
  24.  
  25.   loopCounter = loopCounter + 1;
  26.  
  27.  System.out.println(word + " has " + numberOfVowels + " vowels in total");
  28.  
  29.        if(word == "xxxx" || "XXXX")
  30.   System.out.println("You quit!");
  31.  }
  32.  
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement