Results 1 to 5 of 5
  1. #1
    nfalato is offline Member
    Join Date
    Jan 2017
    Posts
    5
    Rep Power
    0

    Default Count the leading digits of a number

    So I have a similar project where I needed to count the leading digits of imported text files, however I am suppose to remove or "skip" over comments in the program and I am not sure how to exactly do that.

    Each of the comments begin with (* and end with *) and the code that I have for that section is as follows:

    public static boolean hasComments(String s){
    return s.contain ("(*") && s.contains ("*)");
    }

    this falls right under my main method and I don't know how to invoke this method onto the file name that the user inputs.

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: Code to sort the leading digit of a number. 2

    Moved to own thread.

    how to invoke this method
    Call it with a String for an arg and test the value that it returns.
    Last edited by Norm; 01-23-2017 at 11:47 PM.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    nfalato is offline Member
    Join Date
    Jan 2017
    Posts
    5
    Rep Power
    0

    Default Re: Count the leading digits of a number

    What do you mean by "Move to own thread" ?

    Does that mean to move it into the main method? and create another method to call the String from?

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,001
    Rep Power
    33

    Default Re: Count the leading digits of a number

    What do you mean by "Move to own thread" ?
    I said Moved referring to the post being moved from where it was in another thread to its own thread.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    cronnin is offline Member
    Join Date
    Jan 2017
    Posts
    38
    Rep Power
    0

    Default Re: Count the leading digits of a number

    You first need the code to import those text files? Then you set counter to zero and read a file line by line and decide whether you're going to increment the counter or not ( if it's a comment).

Similar Threads

  1. Code to sort the leading digit of a number. 2
    By CreatingDrake in forum New To Java
    Replies: 24
    Last Post: 12-01-2013, 03:59 AM
  2. count every 45 records and prfix the count number
    By dkr786 in forum New To Java
    Replies: 8
    Last Post: 02-15-2013, 07:31 PM
  3. Replies: 8
    Last Post: 01-21-2012, 01:14 AM
  4. Telephone Number To Digits
    By irnie1994 in forum JCreator
    Replies: 1
    Last Post: 10-07-2011, 04:15 PM
  5. Count number of digits in string using scanner
    By wendysbiggy in forum New To Java
    Replies: 35
    Last Post: 01-20-2010, 05:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •