Consider the following code segment. double purchase = 19.93; double payment = 20.00; double change = payment

Question:

Consider the following code segment.
double purchase = 19.93;
double payment = 20.00;
double change = payment - purchase;
System.out.println(change);

The code segment prints the change as 0.07000000000000028. Explain why. Give a recommendation to improve the code so that users will not be confused.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: