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

Username:   Password: 
 RegisterRegister   
 help plz
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
test123




PostPosted: Thu Jan 15, 2004 9:39 pm   Post subject: help plz

I gotta write a processing method that checks for a word in a sentence that is stored into a string variable and finds out how many times that word appears in the sentence and the user also has the ability to match case or whole word.

Right now i can get all the input, but i just can't see how i can check for a word.

I'm not allowed to use any built in methods either.

Any ideas?

This is what i have come up with... I thought that if i use a string it only reads up to a space so once i get the sentence i write some loop that reads the sentence stops and each space takes the word and then stores it in a string array and then i write something to check each array to see if it matches the word. Using ignorecase to match whole word.

Any ideas how i can implement that in code?
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Fri Jan 16, 2004 12:45 am   Post subject: (No subject)

well that wouldn't work since you'd have to be able to match case as well...

you'd have to use substrings to check for matches of parts of the string to the word.

for the "match word" part, you just ass a space to the beginning and end of the word you're looking for. Also add a space to beginning and end of the sentance string to avoid those special first/last word cases
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
test123




PostPosted: Fri Jan 16, 2004 2:37 pm   Post subject: Thanks alot

Thanks alot man.. got it too work.

bits++
rizzix




PostPosted: Fri Jan 16, 2004 3:24 pm   Post subject: (No subject)

he's an admin... don't do that
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: