?

AP® Computer Science A

Free Version

Upgrade subject to access all content

Difficult

Casting

APCSA-YLWN88

The following code prints out "Thirteen divided by 5 is 2.0" The programmer expected the output to say "Thirteen divided by 5 is 2.6.". Which of the following changes to the code will NOT correct this error?

Sample code:

 double x = 13/5;
 System.out.println(Thirteen divided by 5 is " + x);
A

double x = 13.0 / 5;

B

double x = 13/5.0;

C

double x = (double)13/5;

D

double x = 13/(double)5;

E

double x = (double)(13/5);