import java.util.Scanner; public class CastingToInt { public static void main(String[] args) { // Casting an Int 1.6.4 Scanner input = new Scanner(System.in); // Get double value System.out.println("Enter a double: "); double myDouble = input.nextDouble(); // Cast double to an int int castValue = (int) myDouble; // Print double value and after double is cast System.out.println(myDouble); System.out.println(castValue); // Add 0.5 and print again myDouble += 0.5; castValue = (int) myDouble; System.out.println(myDouble); System.out.println(castValue); } }