counting vowels in user-inputted sentence (how??)
Author |
Message |
soulgnat
|
Posted: Wed Dec 17, 2003 5:26 pm Post subject: counting vowels in user-inputted sentence (how??) |
|
|
i need to count the number of vowels and words in a user-inputted sentence..but im not sure how..
Newbie hope you can help
I need it by tomorrow..if anyone would help please? |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Dan
![](http://wiki.compsci.ca/images/archive/3/3c/20100325043407!Danspic.gif)
|
Posted: 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! |
|
|
|
![](images/spacer.gif) |
JayLo
|
Posted: Wed Dec 17, 2003 6:38 pm Post subject: (No subject) |
|
|
would index work? just a guess. |
|
|
|
|
![](images/spacer.gif) |
|
|