Price Calculation with Casting
A program calculates a total price by applying integer casting to a double value to truncate decimals during intermediate steps.
What is printed when the following Java program is compiled and run?
public class QuestionTrace {
public static void main(String[] args) {
double price = 19.99;
int tax = (int) (price * 0.1);
double total = (int) price + tax;
System.out.print(total);
}
}
A
21.99
B
19.0
C
20.0
D
20.99
Question Leaderboard
Not enough data yet to show leaderboard.
