6Retirement Calculator

Your computer knows what the current year is, which means you can incorporate that into your programs. You just have to figure out how your programming language can provide you with that information.

Create a program that determines how many years you have left until retirement and the year you can retire. It should prompt for your current age and the age you want to retire and display the output as shown in the example that follows.

Example Output

 
What is your current age? 25
 
At what age would you like to retire? 65
 
You have 40 years left until you can retire.
 
It's 2015, so you can retire in 2055.

Constraints

  • Again, be sure to convert the input to numerical data before doing any math.

  • Don’t hard-code the current year ...

Get Exercises for Programmers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.