// CSE 142, Spring 2010, Marty Stepp // This program prompts the user to enter his/her age and then prints a // message about how many years remain until the user can retire. // If the user is 65 or over, different messages are printed. // The program demonstrates the Scanner object and if/else statements. import java.util.*; // so that I can use Scanner public class AskAge { public static void main(String[] args) { Scanner console = new Scanner(System.in); System.out.print("How old are you? "); int age = console.nextInt(); if (age > 65) { System.out.println("Damn, you're old!"); } else if (age == 65) { System.out.println("Congratulations! You need diapers now."); } else { int years = 65 - age; System.out.println(years + " years until retirement!"); } } }