problem with showing currency
Hi everyone
could any one please help me to sort the currency type I tried to to use NumberFormat using the getCurrencyInstance(); to get Total but gave me I IIR for currency but I want $ or £ the following is wat i tried
Code:
//programe to print local curency
import java.io.*;
import java.util.*;
import java.text.NumberFormat;
public class LocalCurrency
{
public static void main (String[] args)
{
Scanner myScanner = new Scanner(System.in);
NumberFormat currency = NumberFormat.getCurrencyInstance();
String niceTotal;
double total,quantity,unitPrice,amount;
boolean taxable;
System.out.println("Please enter quantity");
quantity = myScanner.nextDouble();
System.out.println("Please enter unit price");
unitPrice = myScanner.nextDouble();
amount = unitPrice * quantity;
System.out.println("Is taxable? Yes/no");
taxable= myScanner.nextBoolean();
if (taxable = true)
{
total = amount * 1.5;
}
else
{
total = amount;
}
System.out.println(total);
niceTotal=currency.format(total);
System.out.println(niceTotal);
}
}
Re: problem with showing currency
You mean something like:
Code:
System.out.print(Currency.getInstance(Locale.getDefault()).getSymbol());