var wordcounter:int:=0
put "Please enter your fullname,"
get fullname : *
var lengthword:=length (fullname)
put "Hello,", fullname
var count : int := 0
for i : 1 .. length (fullname)
if index (alpha, fullname (i .. i)) > 0 or index (alpha, fullname (i .. i)) > 0 then
count += 1
end if
end for
put "The number of characters in your name is," , count
for counter:1..lengthword
if index ("AEIOUaeiou", fullname (counter))>0 then
wordcounter:=wordcounter+1
end if
end for
I still can't for it to output the percent of the vowels or the number of each vowels... HELP!!! [/code]
Sponsor Sponsor
Jodo Yodo
Posted: Tue Mar 23, 2004 6:22 pm Post subject: (No subject)
Instead of that whole second part, you could've had:
counter:=length (fullname)
That is, unless you didn't want to count the spaces.
dragun
Posted: Tue Mar 23, 2004 6:31 pm Post subject: ok say i input...
If i input lets say <Jerry Seinfeld>
And if AEOUIaeoui each count as 1 and Yy count as 0.5
The output should state
The total # of vowels = 4.5
Total Characters in Name =13
Perecent of name made up of vowels= 34.6%
Any ideas on that twist???
sport
Posted: Tue Mar 23, 2004 6:33 pm Post subject: (No subject)
Index procedure has the form
index (s , patt)
Where s is the word where you look and patt is the pattern and both of them have to be string.
Index returs an integer number and that number is the first occurs of the pattern (patt) in word (s).
nadim
Posted: Tue Mar 23, 2004 6:34 pm Post subject: (No subject)
Yeah didnt want to count the spaces lol if it was only that easy
AsianSensation
Posted: Tue Mar 23, 2004 6:44 pm Post subject: (No subject)
code:
var vowel := "AaEeIiOoUu"
var vcount : array 1 .. 11 of real
for rep : 1 .. 11
vcount (rep) := 0
end for
var word : string
var counter := 0.0
get word : *
for rep : 1 .. length (word)
if word (rep) not= " " then
counter += 1
end if
if index (vowel, word (rep)) > 0 then
vcount (index (vowel, word (rep))) += 1
elsif word (rep) = "Y" or word (rep) = "y" then
vcount (11) += 0.5
end if
end for
for rep : 1 .. 10 by 2
put vowel (rep), " ", (vcount (rep) + vcount (rep + 1)) * 100 / counter, "%"
end for
put "Y ", vcount (11) * 100 / counter
put counter
Twist? what twist? This sounded just like the original program you wanted.....
dragun
Posted: Tue Mar 23, 2004 6:51 pm Post subject: lol
i left the twist out lol although that seem to motivate you lol.... Thanks for the program although havent learned what an array is thanks again
nadim
Posted: Tue Mar 23, 2004 7:09 pm Post subject: Umm.....
how would you put that there is 3 e's in jerry seinfeld?? everything else seems to work fine....
Sponsor Sponsor
Paul
Posted: Tue Mar 23, 2004 7:43 pm Post subject: (No subject)
depends on if your looking for "e"'s in particular, if you are just use index to try and find e in each letter of "Jerry Seinfeld", and add it in a counter, if your not, the use AEIOUaeiou, and do some if statements that if e is found, it adds to the e counter or soemthing.
dragun
Posted: Tue Mar 23, 2004 10:57 pm Post subject: does anybody know .....
You guys have helped alot but before i go to sleep just wanted to ask if anyone knows how to do this program without arrays and just keep it newbish as possible such as just the index and string manipulation...
Paul
Posted: Wed Mar 24, 2004 2:37 pm Post subject: Re: vowel program help
dragun wrote:
Hi, I was wondering if any of you can help me with this program that has been making me go crazy!
Anyways heres what i need to do:
Write a program that asks a user to enter his/her full name (first,middle, and last name) The program should inform the user of how many vowels her/his name contains. Each vowel counts as one and the "y" counts as 1/2> It should also infrom the user what percent of his/her name is made up of vowels.
Thanks for any help given.
ok
code:
var name: string
var vowel, counter: real:=0
put "Put your full name: "
get name:*
for a: 1..length(name)
if index ("AEIOUaeiou", name(a)) not = 0 then
vowel+=1
end if
if index ("yY", name(a)) not =0 then
vowel+=0.5
end if
if index (" ", name(a)) not = 0 then
counter+=1
end if
end for
put "Your name has ", vowel, " vowels in it."
put (vowel/(length(name)-counter))*100, " Percent of your name is vowels."
THis shows percentage minus the spaces in the name.
Jodo Yodo
Posted: Wed Mar 24, 2004 10:30 pm Post subject: (No subject)
Here's a more literal code that isn't very efficient, but gives the percentage of vowels and the number of them, and also ignore spaces.
code:
var words : string
var acounter, ecounter, icounter, ocounter, ucounter, ycounter : int := 0
var lword : int
var vowels : int := 0
var percentage : real
get words : *
lword := length (words)
for counter : 1 .. lword
if words (counter) = "A" or words (counter) = "a" then
acounter += 1
elsif words (counter) = "E" or words (counter) = "e" then
ecounter += 1
elsif words (counter) = "I" or words (counter) = "i" then
icounter += 1
elsif words (counter) = "O" or words (counter) = "o" then
ocounter += 1
elsif words (counter) = "U" or words (counter) = "u" then
ucounter += 1
elsif words (counter) = "Y" or words (counter) = "y" then
ycounter += 1
elsif words (counter) = " " then
lword := lword - 1
end if
end for