This site requires JavaScript, please enable it in your browser!
Greenfoot back
rockon411
rockon411 wrote ...

2017/4/6

Returning Sum

rockon411 rockon411

2017/4/6

#
I have a data set of numbers and phrases like looks like this
0 I don't like you
1 Don't talk to me
3 I really like you
But it goes on for a while and I am supposed to be able to create an int method that, given the word, returns the sum of the numbers of associated with them. Like for this data set I the sum for "you" would be 3. I was thinking a for loop but I'm not really sure. Any help would be appreciated!
Nosson1459 Nosson1459

2017/4/6

#
rockon411 wrote...
I have a data set of numbers and phrases
How is this data formatted when you get it?
danpost danpost

2017/4/6

#
rockon411 wrote...
I was thinking a for loop but I'm not really sure.
A for loop to iterate through all the sets and add to an Integer value when the given word is found within the String part of a set would work.
rockon411 rockon411

2017/4/8

#
Thanks!
You need to login to post a reply.