Results 1 to 2 of 2

Thread: problem with showing currency

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2007
    Posts
    39

    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);
        }
    }

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: problem with showing currency

    You mean something like:
    Code:
    System.out.print(Currency.getInstance(Locale.getDefault()).getSymbol());
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

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