Java Expression with Type Casting
Consider the following code segment.
Scanner scan = new Scanner(System.in);
System.out.print("Enter a decimal number: ");
double value = scan.nextDouble();
int result = (int)(value + 0.5);
Assuming the user enters 7.3 as input, what value will be stored in the result variable after the code executes?
A
7.3
B
8
C
7.8
D
7
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | sgarv2513 | 2 | 3 | 0m 00s | 190 |
| #2 | mali.nehme | 1 | 1 | 0m 00s | 100 |
| #3 | angelajxi11 | 0 | 1 | 0m 00s | -10 |
Items per page:
10
1 – 3 of 3
APFIVE