Menu
Coddy logo textTech

Recap - Years Until Retirement

Part of the Fundamentals section of Coddy's Kotlin journey. Lesson 39 of 93.

challenge icon

Challenge

Easy

Write a function yearsUntilRetirement that takes currentAge and retirementAge and returns the number of years remaining until retirement.

Calculate the difference between the retirement age and the current age.

Parameters:

  • currentAge (Int): The person's current age
  • retirementAge (Int): The target retirement age

Returns: The number of years until retirement (Int)

Try it yourself

fun yearsUntilRetirement(currentAge: Int, retirementAge: Int): Int {
    // Write code here
}

All lessons in Fundamentals

Practice on your own: Kotlin playground