Experiment with Casting
In this activity, you will make predictions regarding the outcome of given expressions. You will use the Java Playground to test your predictions. In these exercises, we use IO instead of System.out. The results are the same. Feel free to edit the output statements to use System.out if you prefer.
Grab a Piece of Paper, Predict and Try!
- Take some time to predict the value of each expression and corresponding output.
- Test your predictions by running the code in the Java Playground below.
- For any expression where your prediction and the actual value differs, write an explanation of how the expression is evaluated.
Practice Writing Code
|
Grab a Piece of Paper! |
In each practice set, write the draft code on a piece of paper or white board. Try your code out in the Java Playground. |
Practice 1: Rounding Temperature
Write code to display the value of temperature rounded to the nearest int value.
Practice 2: Calculate Average
Write code to calculate and display the average.
Practice 3: Convert Minutes to Hours
Write code to convert the number of minutes to the number of hours by using casting.