Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 counting vowels in user-inputted sentence (how??)
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
soulgnat




PostPosted: Wed Dec 17, 2003 5:26 pm   Post subject: counting vowels in user-inputted sentence (how??)

Crying or Very sad Crying or Very sad i need to count the number of vowels and words in a user-inputted sentence..but im not sure how..

Newbie Smile hope you can help
I need it by tomorrow..if anyone would help please?
Sponsor
Sponsor
Sponsor
sponsor
Dan




PostPosted: Wed Dec 17, 2003 6:37 pm   Post subject: (No subject)

well we tend to be more helpfull when you post an atamped socrce code with your question, see we have had a problem with poleop whonting us to do there hw for them.

for this i whould recomend making an array of chars that holds vowels:

code:

var vowles: array 1..10 of char
vowles(1) := 'a'
vowles(2) := 'e'
vowles(3) := 'i'
vowles(4) := 'o'
vowles(5) := 'u'
vowles(6) := 'A'
vowles(7) := 'E'
vowles(8) := 'I'
vowles(9) := 'O'
vowles(10) := 'U'


i am not shure if you know about array's but it whould be the easetes way to do this question, for more info on them check out our tutorials

next you need to make a loop that will run as many times as there are letters in the input and one that will run as many times as there are vowles to check

length(string) will return the length of a given string

so your code will look somting like this

code:

for i: 1.. length(userInput)
     for ii: 1..10
          .....code here.....
    end for
end for


now you will need an if stament in this for loop that will uses substrings to check if any of the letters in our array is in the string.

code:

if userInput (i) = vowles (ii) then
            couter := couter + 1
end if


and there you go you will have the number of vowles in your couter varible.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
JayLo




PostPosted: Wed Dec 17, 2003 6:38 pm   Post subject: (No subject)

would index work? just a guess.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: