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


4 Years
Discussion Span
Last Post by Doogledude123

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.