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
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.
Step by Step Solution
3.49 Rating (156 Votes )
There are 3 Steps involved in it
Java double is utilized to address floating point or decimal numbers It utilizes 64 bits to store a ... View full answer
Get step-by-step solutions from verified subject matter experts
