Creating an application to determine the adulthood status

Report a typo

You are building a simple application in Kotlin that will display user's name and age and determine if they are an adult. You have a variable 'name' with a value 'John' and 'age' with a value 22. You need to print a statement like 'John is 22 years old. Adult? Yes'. To determine if the user is adult, you'll write an expression that tests if the age is greater or equal to 18 and output either 'Yes' when true, or 'No' when false. You should fill the blanks in code to create a resulting message using string templates.

Fill in the gaps with the relevant elements
fun main() {
    val name = "John"
    val age = 22
    val isAdult =  (age >= 18) "Yes"  "No"
    println("$name is ${age} years old. Adult? $isAdult")
}
ifelse
___

Create a free account to access the full topic