• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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
 
Your mother was a hamster and your father was a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic