Results 1 to 3 of 3

Thread: formatting?[Resolved]

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2002
    Posts
    103

    formatting?[Resolved]

    x = 29.9
    y = 354
    z = 18.80

    is there any way i can format them to:

    x = 29.90
    y = 354.00
    z = 18.80

    dealing in dollars...
    Last edited by Dilenger4; Jun 27th, 2003 at 09:45 PM.

  2. #2
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    Code:
      import java.util.Locale; 
      import java.text.NumberFormat;
      
      public class B{
        public static void main(String[] args){
    
        double x = 29.9; 
    
        NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.US); 
        System.out.println(nf.format(x)); 
    
        NumberFormat nf2 = NumberFormat.getCurrencyInstance(Locale.JAPAN); 
        System.out.println(nf2.format(x)); 
    
        NumberFormat nf3 = NumberFormat.getCurrencyInstance(Locale.GERMANY);    
        System.out.println(nf3.format(x)); 
      }
    }

  3. #3
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    quipy. you should go through some of your threads that you posted and add {resolved} to the title if the you happened to figure out the problem either on your own or by the help of another member. It's just helps people who are browsing the forum to see what posts have been answered already. I also went through some of my threads and added resolved to the ones that i either figured out or got an answer to.

Posting Permissions

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



Click Here to Expand Forum to Full Width