// CSE 142, Autumn 2010 // Author: Jessica Miller // This program uses a Scanner object to (a) read in how many times to ask // for the user's age and (b) read in the user's age. It takes the last age // entered and calculates the age until the user retires. import java.util.*; // so that I can use Scanner public class UserInputExample { public static void main(String[] args) { Scanner console = new Scanner(System.in); System.out.print("How many times should I annoy you? "); int numTimeToPrompt = console.nextInt(); int age = 0; for (int i = 1; i <= numTimeToPrompt; i++) { System.out.print("How old are you? "); age = console.nextInt(); } int years = 65 - age; System.out.println(years + " years until retirement!"); } }