Write a program that takes a person's name and age as input, and prints a greeting message using string templates. The message should include the person's name and the year they were born, assuming the current year is 2023.
String templates
Greeting with birth year calculation
Report a typo
Sample Input 1:
Alice
25Sample Output 1:
Hello Alice! You were born in the year 1998.Sample Input 2:
Bob
12Sample Output 2:
Hello Bob! You were born in the year 2011.Write a program in Kotlin
fun main() {
// Read the person's name and age from the console
val name = readln()
val age = readln().toInt()
// Calculate the birth year
val birthYear = 2023 - age
// Print the greeting message using string templates
}
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.