Doppelte Anzeige einer sehr langen Zahl
Ich habe eine einfache Berechnung, bei der das Doppelte verwendet wird, aber ich erhalte ein unerwartetes Ergebnis und kann nicht verstehen, warum?
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.");
}
}
Wenn ich 2,99 eingebe, erhalte ich das Ergebnis ..
We will bill $27.990000000000002 to your credit card.