Here the problem is when I add amountbeforetax which is 68.0 with tax amount which is 14.96, it is giving me amountWithTax is equal to 82.96000000000001, but when i add with tax amount which is 14.97 or 14.95, 14.98 it is giving me proper value.
what is the problem here? why it is giving me such result?
public class Calc {
public static void main(String[] args) {
double discountAmount = 0;
double amountBeforeTax = 0;
double amountWithTax = 0;
double taxAmount = 0;
amountBeforeTax = 68.0;
System.out.println("amountBeforeTax "+amountBeforeTax);
taxAmount = 14.96;
System.out.println("taxAmount "+taxAmount);
amountBeforeTax-= discountAmount;
System.out.println("amountBeforeTax after discount "+ amountBeforeTax);
amountWithTax = amountBeforeTax + taxAmount;
System.out.println("amountWithTax "+ amountWithTax);
}
}