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));
}
}
andi-dev 0 Light Poster
stultuske 1,116 Posting Maven Featured Poster
ishaan3731 -3 Newbie Poster
jwenting 1,889 duckman Team Colleague
Doogledude123 45 Posting Whiz
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.