public class NumFormat {
    public static void main (String [] args ){
    int quarter = 2;
    int dollars = 3;
    double total = dollars + quarter * 0.25;
    final double TAX_RATE = 8.5;
    double tax = total * TAX_RATE ;
    NumberFormat formatter = NumberFormat.getNumberInstance ();
    formatter.setMaximumFractionDigits (2);
    System.out.println ("Totali:$" + total);
    System.out.println ("Taksa: $" + formatter.format (tax));




    }

}

Recommended Answers

and what is the 'LITTLE PROBLEM' you are referring to?
a suggestion: let your title describe the type of issue. don't make us guess as to what the problem is, make it clear in your post.
provide all information: does it produce unexpected output? what do you expect? what do …

Jump to Post

All 4 Replies

and what is the 'LITTLE PROBLEM' you are referring to?
a suggestion: let your title describe the type of issue. don't make us guess as to what the problem is, make it clear in your post.
provide all information: does it produce unexpected output? what do you expect? what do you get?
is an exception thrown? do you get a stacktrace? what does it say?

well, can see one little problem already. Your "tax rate" is hopefully a percentage, not a rate.
If it's really a rate you have 850% tax :)

If you aren't getting the proper amount back, as jwenting said, if you expect it as a percent you need to divide it by 100.
Also, I would put some brackets in there for easier reading, and sometimes they matter.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.