Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

count of operands

 
Kishore
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote a code to count the number of operators and operands in a file. I was able to calculate the count of operators, but stuck at the operands. Do i need to use hasNextToken() method, or something else. Please Help this novice.
Thank you,
Kishore Kumar Bokkala
 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post your code, using the *code* tags, thanks.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can imagine a couple of different solutions - one using a StringTokenizer that would use the operators as the delimiters, and one using regular expressions. Do you have any ideas?
 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
This approach won't work; have a look at the expression 'x+a- -b' (note the space character). Simply checking for '+' and/or '-' tokens in the sequence isn't gonna help you; are we talking three operands here? three operators and four operands in total? I think the original question has to be rephrased a bit before a reasonable answer can be given ...
kind regards
 
Sanju
Ranch Hand
Posts: 53
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi kishore...
Plz post ur code...
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic