Results 1 to 8 of 8
  1. #1
    javauserjava is offline Member
    Join Date
    Mar 2011
    Posts
    27
    Rep Power
    0

    Default Dollar sign and DecimalFormat

    Hi everyone,

    I hope you are having a nice day,, I've variable that has to be with the dollar sign for example $10.00 and I used the following line of codes

    Java Code:
    DecimalFormat numberformat = new DecimalFormat("$ ##,###.##");
    
    String PSALESIN;

    Java Code:
    PSALESIN = numberformat.format(Integer.parseInt(PRODUCTSALESPRICEIN.readLine()));

    The problem with the previous code is give me out put such as $10

    your help is really appreciated,,

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    6

    Default

    DecimalFormat (Java Platform SE 6)
    # [...] zero shows as absent
    -->
    Java Code:
    "$##,###.00"
    :confused:

  3. #3
    javauserjava is offline Member
    Join Date
    Mar 2011
    Posts
    27
    Rep Power
    0

    Default

    Thank you so much,, I like the face that you put it at the end,,

    also I have faced a problem with the following code which should create a random number .. could you please take a look on it because it gave me a REPEATED VALUE..


    Java Code:
     Calendar CURRENTDATE = Calendar.getInstance ();
        int CURRENTTIME = CURRENTDATE.get (Calendar.MILLISECOND);
    
            int CURRENT9 = 50;
            int RANDNUMBER = 560;
            int NUM = CURRENTTIME + CURRENT9;
            int SIDOUT = (RANDNUMBER / CURRENT9) + NUM;
            int PIDOUT = (RANDNUMBER / NUM) + NUM;
    
                    PIDOUT = RANDNUMBER + PIDOUT;
                    SIDOUT = RANDNUMBER + SIDOUT;
                    SIDOUT = PIDOUT + SIDOUT;
                    PIDOUT = SIDOUT + PIDOUT;
                    int PID = PIDOUT / CURRENT9;
                    int PIDOUT1 = PIDOUT % CURRENT9;
                    int SID = SIDOUT / PID;
                    int SIDOUT1 = SIDOUT % PID;
    Thanks in advanced ,,

  4. #4
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    6

    Default

    because it gave me a REPEATED VALUE
    :confused: Which value?!

    This question has nothing to do with the initial question or?

  5. #5
    javauserjava is offline Member
    Join Date
    Mar 2011
    Posts
    27
    Rep Power
    0

    Default

    this algorithm should give me a new number in each line for example ,

    102232
    213093
    213302
    109032

    but unfortunately it gave me results same as the following which is not correct

    1233
    1233
    1233
    4323
    4323
    5334
    5334


    Hope it is clear..

  6. #6
    javauserjava is offline Member
    Join Date
    Mar 2011
    Posts
    27
    Rep Power
    0

    Default

    I am so sorry but if there is any help for this problem that will be great.

    I know I can use the random class in Java but the problem is I have to use this algorithm and I have to fix it..

  7. #7
    santeron is offline Member
    Join Date
    Apr 2011
    Location
    Athens, Greece
    Posts
    52
    Rep Power
    0

    Default

    Mate that is a totally different question than the one you did at first. Open a new thread so people can help you and mark this as solved... :)

  8. #8
    javauserjava is offline Member
    Join Date
    Mar 2011
    Posts
    27
    Rep Power
    0

    Default

    Okay, I did not know that,, I will do it write now,,

    Thanks for the advice

Similar Threads

  1. Dollar sign in a while statement
    By oneprotect in forum Advanced Java
    Replies: 3
    Last Post: 01-18-2011, 11:01 AM
  2. locale and decimalFormat confusion
    By bz3x in forum New To Java
    Replies: 2
    Last Post: 05-23-2010, 12:22 AM
  3. problem sending Dollar symbol in SMS
    By neerajsaxena in forum Advanced Java
    Replies: 1
    Last Post: 01-28-2010, 06:37 PM
  4. Replies: 1
    Last Post: 10-20-2008, 07:35 AM
  5. DecimalFormat class
    By Java Tip in forum Java Tip
    Replies: 1
    Last Post: 12-30-2007, 03:09 PM

Posting Permissions

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