Results 1 to 11 of 11
Thread: Help ..
- 04-29-2011, 02:12 PM #1
Member
- Join Date
- Apr 2011
- Posts
- 5
- Rep Power
- 0
- 04-29-2011, 02:23 PM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 339
- Rep Power
- 5
The 'Logic' section of the question is gibberish.
- 04-29-2011, 02:40 PM #3
Member
- Join Date
- Apr 2011
- Posts
- 5
- Rep Power
- 0
- 04-29-2011, 02:56 PM #4
Senior Member
- Join Date
- Jun 2008
- Posts
- 339
- Rep Power
- 5
You think?
Perhaps you could explain it to me as you understand it, because it's not clear to me.the main idea from the question isn't clear ? :(
My view is that programming can be hard work, and I want to be absolutely sure before doing any hard work that I understand exactly what I'm supposed to do.
- 04-29-2011, 03:20 PM #5
Member
- Join Date
- Apr 2011
- Posts
- 5
- Rep Power
- 0
He didn't explain to us ..Perhaps you could explain it to me as you understand it, because it's not clear to me.
yes , I know that .Perhaps you could explain it to me as you understand it, because it's not clear to me.
My view is that programming can be hard work, and I want to be absolutely sure before doing any hard work that I understand exactly what I'm supposed to do.
I work hard to order my ideas but i don't know what should I do first .
umm , Can we try to understand and write it together ?
if you want . :o
- 04-29-2011, 03:42 PM #6
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
The logic description isn't great, however; the input output examples are helpful.
Seems like the goal is to take a string array and a search term, then, for each element in the array you want to find the number of times the search term is found. You then add that to a new string array and continue. Finally you return the array. Try something out and show us your attempts
[code]
YOUR CODE HERE
[/code]
Use code tags like above when posting code.
Java Code:declare string array loop loop search for number of times search term was found end loop add string to return array end loop
- 04-29-2011, 04:11 PM #7
Senior Member
- Join Date
- Jun 2008
- Posts
- 339
- Rep Power
- 5
- 04-29-2011, 04:12 PM #8
Member
- Join Date
- Apr 2011
- Posts
- 5
- Rep Power
- 0
Look how I see it .
The method should starts from first row and looking for the search word, and when it find the search word the counter became 1 , until the end of this row it prints this " word" (search word) "found" (counter) "time"
and down to another row and do the same thing , umm, do you think the counter should be zero whenever down a new row ?
is that right ?
sorry but I'm new in java .. :(
Yes , I'm wrote this from the table or whatever .The logic description isn't great, however; the input output examples are helpful.
Thank you very much . ^^Last edited by Dnav; 04-29-2011 at 05:22 PM.
- 04-29-2011, 04:26 PM #9
Member
- Join Date
- Apr 2011
- Posts
- 5
- Rep Power
- 0
- 04-29-2011, 04:53 PM #10
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,588
- Blog Entries
- 7
- Rep Power
- 17
- 04-29-2011, 05:54 PM #11
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
I believe I am going to have to side with jos. That logic description seems a bit jumbled, is that actually the exact handout your teacher gave you? If it is I am pretty surprised that the logic isn't a bit more concise.
One important thing is to think about the problem constantly. The better you understand it, the easier the coding process will begin.
Each element in the array is a string, so you could make a method, or have your logic take two strings, search term, and the to be searched string. From there you can count the number of occurrences of the search term in the original string.
This is breaking the problem down to a smaller problem. Once you do this it shouldn't be hard to expand this onto multiple items in the array.
then this method could be used in the other method. Alternatively, you don't need to use this method, but writing it should be helpful. For new programmers nested loops can be confusing and doing it this way does use nested loops but it allows you to think about them separately.Java Code:public int countString(String toBeSearched, String searchTerm)
Finally, my pseudo code above should be very helpful. Also, consider asking for clarification from the teacher.


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks