Menu
Coddy logo textTech

Recap - True or False

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

challenge icon

Challenge

Easy

Read two integers and one string as input, then determine if a person can enter a venue.

You will receive three inputs:

  • First input: the person's age (as a string, convert to Int)
  • Second input: the minimum required age (as a string, convert to Int)
  • Third input: whether they have a ticket - either "true" or "false" (convert to Boolean)

A person can enter if their age is greater than or equal to the minimum age AND they have a ticket.

Print the result in this exact format:

Can enter: [result]

Where [result] is true or false based on the conditions.

Try it yourself

fun main() {
    // Read inputs
    val ageInput = readLine()!!
    val minAgeInput = readLine()!!
    val hasTicketInput = readLine()!!
    
    // TODO: Write your code below
    // 1. Convert ageInput and minAgeInput to Int
    // 2. Convert hasTicketInput to Boolean
    // 3. Determine if the person can enter (age >= minAge AND has ticket)
    
    // Output the result in the format: Can enter: [result]
    println("Can enter: $canEnter")
}

All lessons in Fundamentals

Practice on your own: Kotlin playground