formatting number

Discussion in 'Java' started by mank, Oct 18, 2004.

  1. mank

    mank Guest

    I have to write a method which is supposed to do the following -

    When input is 2.00, it converts to $2
    When input is 2.01, it converts to $2.01
    When input is 2, it converts to $2

    Is there any utility method in java which can do that?
    mank, Oct 18, 2004
    #1
    1. Advertising

  2. mank

    Paul Lutus Guest

    mank wrote:

    > I have to write a method which is supposed to do the following -
    >
    > When input is 2.00, it converts to $2
    > When input is 2.01, it converts to $2.01
    > When input is 2, it converts to $2
    >
    > Is there any utility method in java which can do that?


    Yes, you can use class DecimalFormat to do it. Because this is very likely a
    homework assignment, if you will post your code, someone here will help you
    get it working.

    --
    Paul Lutus
    http://www.arachnoid.com
    Paul Lutus, Oct 18, 2004
    #2
    1. Advertising

  3. mank

    Alex Hunsley Guest

    mank wrote:
    > I have to write a method which is supposed to do the following -
    >
    > When input is 2.00, it converts to $2
    > When input is 2.01, it converts to $2.01
    > When input is 2, it converts to $2
    >
    > Is there any utility method in java which can do that?


    This question is much more suited to comp.lang.java.help.
    As Paul said, post the code you have so far, and what it's doing wrong.
    This newsgroup ain't a code generating machine.
    Alex Hunsley, Oct 19, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. rguti

    Number formatting

    rguti, Jun 10, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    394
    Craig Deelsnyder
    Jun 10, 2004
  2. Luis Esteban Valencia

    Formatting decimal number

    Luis Esteban Valencia, Jan 12, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    526
    Philip Q [MVP]
    Jan 12, 2005
  3. probashi

    Number Formatting Question C#

    probashi, Feb 23, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    15,959
    Karl Seguin
    Feb 23, 2005
  4. thomson

    Number Formatting

    thomson, Aug 3, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    355
  5. Thor W Hammer

    Formatting a number without rounding

    Thor W Hammer, Nov 22, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    491
    Karl Seguin
    Nov 22, 2005
Loading...

Share This Page