I have a simple calculation that uses doubles but I'm getting an unexpected result and I can't understand why?
import java.util.Scanner;
public class VersatileSnitSoft {
/**
* @param args
*/
public static void main(String[] args) {
Scanner myScanner = new Scanner(System.in);
double amount;
System.out.print("What’s the price of a CD-ROM? ");
amount = myScanner.nextDouble();
amount = amount + 25.00;
System.out.print("We will bill $");
System.out.print(amount);
System.out.println(" to your credit card.");
}
}
If I enter 2.99 the result I get is..
We will bill $27.990000000000002 to your credit card.