Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

trapping two appearance of a character

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

pls don't laught ! can't think of any stuff to make it work

[fbr - added code tags]
[ December 11, 2007: Message edited by: Fred Rosenberger ]
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by joseph okon:

pls don't laught ! can't think of any stuff to make it work

[fbr - added code tags]

[ December 11, 2007: Message edited by: Fred Rosenberger ]



One error I can see is that you are trying to use equals to compare two integers. Primitive data types (such as int) don't have methods. You need to use == to compare them.

Fix that and if it still doesn't compile, post the error messages you are getting (exactly as they appear). Once it's compiling we can then tackle the logic.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've made a few modifications -marked in bold- to help you get going. What's missing is the spot labelled "TODO". What needs to happen there to make the code work?
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
As pointed out by folks above, there are some erroes in your code.Find below a simple piece of code that achieves what your code would have(more than 2 @).I have done away with the countChar method.
Incase you want to count how many times "@" appears,you need to modify countChar method



Shane
 
joseph okon
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks guys, i have gotten the right answer to my code
 
reply
    Bookmark Topic Watch Topic
  • New Topic