Computer Program Reading Comprehension Project
U of T Computer Program Reading Comprehension Project
Typecast
Compute 100/3.

Download files: TypeCast.java
Areas: Primitive types.


TypeCast.java
1float result;
2result = 100 / 3;
3System.out.println("result = " + result);


Question 1
What is the value of result after line 2?
Hints Solution

Question 2
Is the following expression more accurate: result = (float)(100 / 3);?
Solution

Question 3
How can you change the expression to get a more accurate result?
Hints Solution