PDA

Click to See Complete Forum and Search --> : formatting?[Resolved]


quipy
May 28th, 2003, 08:40 AM
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...

Dillinger4
May 28th, 2003, 02:31 PM
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));
}
}

Dillinger4
Jun 13th, 2003, 12:44 AM
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. :)